Home >>C Tutorial >Macros In C

Macros In C

Macros In C

The Macros in C are basically a fragment of the code that has been given a name. The name is replaced by the contents of the macro, whenever the name is used.

There are generally two types of macros in C. The types of C macro function generally differ in their looks when they are used. Object-like macros are known to resemble the data objects that are when used they function-like the macros that resemble function calls.

Macro definition in C is generally can be defined by the programmer by any valid identifier as a macro, even though it is a C keyword. The preprocessor operator defined can not be defined as a macro in C language.

Here is an example of the Macros in C language that will give you a basic understanding of the topic:

#define PI 3.1415
int main()
    float radius,area;
    printf("Plese Enter the radius ");
    scanf("%f", &radius);
    //Here used the value  of PI
    area = PI*radius*radius;
    return 0;
Output : Plese Enter the radius 10