What is a macro in C?

Macros are used to define constants values of variables. The value which we assign to a variable by using macro makes it a constant and we can use that variable anywhere in the program. In order to change the value of the variable we can change it its macro declaration rather than changing its value everywhere in the program where that variable is used.

Eg.:

#define pie 3.142 //Defining a Macro

Void main ()

{

Int r;

Float ar;

Printf (“Enter radius”);

Scanf(“%d”, &r);

Ar= pie*r*r;

Printf(“Area is %f”,ar);

Getch();

}

More Questions

Leave a Reply

Word Verfication * Time limit is exhausted. Please reload CAPTCHA.