[an error occurred while processing this directive]

C define Macro

                         

This section illustrates you how to use macros in C.

Macros are the identifiers that represent statements or expressions. To associate meaningful identifiers with constants, keywords, and statements or expressions,  #define directive is used. You can see in the given example, we have define a macro i.e SQUARE(x) x*x. Here the macro determines the square of the given number.

Macro Declaration:     #define name text

Here is the code:

DEFINEMA.C


#include <stdio.h>
#include <conio.h>
#define SQUARE(xx*x
int main() {
  int i = 2;
  int j= SQUARE(i);
  printf("The value of j is: %d\n", j);
  getch();
  return 0;
}

Output will be displayed as:

DEFINEMA.EXE

Download Source Code:

                         

[an error occurred while processing this directive]