Symbolic Constants (Global Values)

 #define:

                It is a pre-processor statement and is used to define symbolic constants.

Syntax:

                #define    identifier    value

Eg:            #define  pi  3.14

                  #define  g   9.8

Program:

#include<stdio.h>

#include<conio.h>

#define  pi  3.14

#define  g  9.8

#define val 200

void main()

{

    clrscr();

    printf("pi = %.2f", pi);

    printf("\ng = %.2f", g);

    printf("\nval = %d", val);

    getch();

}


Output:

pi = 3.14

g = 9.8

val = 200



Next Topic        :  scanf statement

Previous Topic :  Constants

No comments:

Post a Comment