Do a calculation on float number : float Calculation « Data Type « C Tutorial






#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    float height_in_cm;
    char height_in_inches[4];
 
    printf("Enter your height in inches:");
   
    gets(height_in_inches);
   
    height_in_cm = atoi(height_in_inches) * 2.54;
   
    printf("You are %.2f centimeters tall.\n",height_in_cm);
   
    return(0);
}
Enter your height in inches:1
      You are 2.54 centimeters tall.








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