Sail E0 Webinar
Question

What would be output of the program ?

#include<stdio.h>
#define X 5+2
void main()
{
int i;
i = X*X*X;
printf("%d",i);
}


Options:
A .  343
B .  27
C .  133
D .  Compiler Error
E .  None of the above
Answer: Option B


As we know #define is a token pasting preprocessor it only paste the value of micro constant in the program, before the actual compilation start.
So pasting 5+2 in place of X, we have
i = 5+2*5+2*5+2
 = 5+10+10+2
= 27



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers