#define

The #define preprocessor takes the form: #define identifier value

 

#include <stdio.h> //allows the use of the printf() function in the stdio.h library file

#define PI 3.14
#define RADIUS 20   

int main()
{
   int area ;

   area = PI * (RADIUS * RADIUS) ;
   printf("A circle with a radius of 20cm has an area of: %d cm.", area) ;

   return 0 ;
}

Compile & run:

A circle with a radius of 20cm has an area of: 1256 cm.

Leave a Reply