define identifier token_string - Devbhoomi

FREE JOB ALERT & ONLINE TUTORIALS

Hot

Post Top Ad

Sunday 5 November 2017

define identifier token_string

token_string : is optional but, are used almost every time in program.
E.g.
#define x 2

    
Whenever x occurs, it is replaced by the token string 2.

Example :

    #include <stdio.h>
    #define PI 3.1415
    int main()
    {
    int radius;
    float area;

    printf("Enter the radius : ");
    scanf("%d",&radius);

    area=PI*radius*radius;
    printf("\nArea=%.2f",area);
    return 0;
    }

Output :
Enter the radius : 2
Area=12.57


Explanation :
The PI is a define directive and is replaced by its value in every occurrence.

No comments:

Post a Comment

Post Top Ad