Define float constant value using Macro : float Declaration « Data Type « C Tutorial






#include <stdio.h>
#define PI   3.14159f               

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

  printf("Input the diameter of a 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", area);
  return 0;
}
Input the diameter of a table:123
     
     The circumference is 386.42
     The area is 11882.28








2.18.float Declaration
2.18.1.Floating Point variables
2.18.2.The form of a floating-point declaration
2.18.3.Define float variable and output to the console
2.18.4.Define float in In scientific notation (The E notation)
2.18.5.Define float constant value using Macro
2.18.6.Assignment of an integer expression to a floating-point variable.