C-#define .

In this session i have discussed #define preprocessor in C .


The #define preprocessor directive is used to define constant or macro in program .


Syntax

#define identifier value


Example : Write a program that demonstrate the use of #define .

    #include<stdio.h>
    #define PI 3.14
    int main()
    {
        int r;
        float area;
        printf("Enter the radious");
        scanf("%d",&r);
        area=PI*r*r;
        printf("Area : %f",area);
        
        return 0;
    }
    
    OUTPUT : Enter the radious : 2
             Area : 12.560000
    

In the above code i have define the PI as macro in this program .


Welcome to AndroidATPoint.

back image                     next image