Macros can contain library functions such as printf() - C Preprocessor

C examples for Preprocessor:Macro

Description

Macros can contain library functions such as printf()

Demo Code

#include <stdio.h> 

#define RESULT(x,y) ( printf("\nResult is %d\n", x+y) ) 

int main() { /* ww  w  . ja v a  2 s .  c  o m*/
   int num1 = 0; 
   int num2 = 0; 
   printf("\nEnter first number: "); 
   scanf("%d", & num1); 
   printf("\nEnter second number: "); 
   scanf("%d", & num2); 
   RESULT(num1, num2); 
   
   return 0;
}

Result


Related Tutorials