Home » C Programming » C Preprocessor

What will be the output of the program? #include #define PRINT(int) printf("int=%d, ", int); int main() { int x=2, y=3, z=4; PRINT(x); PRINT(y); PRINT(z); return 0; }

Correct Answer: int=2, int=3, int=4

Explanation:

The macro PRINT(int) print("%d,", int); prints the given variable value in an integer format.


Step 1: int x=2, y=3, z=4; The variable x, y, z are declared as an integer type and initialized to 2, 3, 4 respectively.


Step 2: PRINT(x); becomes printf("int=%d,",x). Hence it prints 'int=2'.


Step 3: PRINT(y); becomes printf("int=%d,",y). Hence it prints 'int=3'.


Step 4: PRINT(z); becomes printf("int=%d,",z). Hence it prints 'int=4'.


Hence the output of the program is int=2, int=3, int=4.


← Previous Question Next Question→

More Questions from C Preprocessor

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion