Define

Syntax:

#define token (value);

You can assign value in variable through #define keyword. For example:
If you write #define PI (3.1416), the value (3.1416) will be assigned in PI.

#include<stdio.h>
#define PI (3.1416)
int main()
{
    printf("PI = %f ",PI)
   return 0;
}

OUTPUT

PI = 3.141600

Once you assign value through #define keyword, you can’t changed the value again. In this point of view const and #define keywords are same. But there are some deference between const and #define. Next, we will describe this in derails.


Next Previous