C Programming - C Preprocessor - Discussion
Discussion Forum : C Preprocessor - Find Output of Program (Q.No. 14)
14.
What will be the output of the program?
#include<stdio.h>
#define PRINT(i) printf("%d,",i)
int main()
{
int x=2, y=3, z=4;
PRINT(x);
PRINT(y);
PRINT(z);
return 0;
}
Answer: Option
Explanation:
The macro PRINT(i) print("%d,", i); 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("%d,",x). Hence it prints '2'.
Step 3: PRINT(y); becomes printf("%d,",y). Hence it prints '3'.
Step 4: PRINT(z); becomes printf("%d,",z). Hence it prints '4'.
Hence the output of the program is 2, 3, 4.
Discussion:
2 comments Page 1 of 1.
Wikiok said:
1 decade ago
Nothing. It is just printed out as a simple character.
Vinoth said:
1 decade ago
What is mean by comma inside field specification?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers