#define in C

define in C

In the C Language, the #define directive allows the definition of macros within your source code.

Macro definitions are not variables and cannot be changed by your program code like variables.

#include <stdio.h>
#define PI 3.14159

int main ()
//pi = 3.1416
{
    float area, r;
    scanf("%f", &r);

    area = PI * (r * r);

    printf("area is %f", area);

    return 0;

}

//enter 3 

Output

area is 28.274309
Tags: , ,