Read float number and do a calculation : float Calculation « Data Type « C Tutorial






#include <stdio.h>

int main(void)
{
  float radius = 0.0f;              
  float diameter = 0.0f;            
  float circumference = 0.0f;       
  float area = 0.0f;                
  float Pi = 3.14159265f;

  printf("Input the diameter of the table:");
  scanf("%f", &diameter);           
  radius = diameter/2.0f;           
  circumference = 2.0f*Pi*radius;   
  area = Pi*radius*radius;          
  printf("\nThe circumference is %.2f", circumference);
  printf("\nThe area is %.2f\n", area);
  return 0;
}
Input the diameter of the table:123
     
     The circumference is 386.42
     The area is 11882.29








2.21.float Calculation
2.21.1.Division with float values
2.21.2.Read float number and do a calculation
2.21.3.Do a calculation on float number