The output of the following program is:
#define f(g,g2) g##g2
void main()
{
int var12=100;
printf("%d", f(var,12));
}
#define f(g,g2) g##g2
void main()
{
int var12=100;
printf("%d", f(var,12));
}
A. Syntax error
B. Runtime error
C. g##g2
D. 100
E. 10012
Answer: Option D
Solution(By Examveda Team)
## is token pasting operator which simply combines all the parameters of macro into one variable.
So, in f(var, 12), var and 12 combines to form var12 and replaces the f(var, 12) and hence the output is 100.
Related Questions on C Preprocessor
What is the purpose of the C preprocessor in C programming?
A. Compile C code
B. Optimize code
C. Preprocess code before compilation
D. Execute code
A. #define
B. #include
C. #ifdef
D. #pragma
What is the purpose of the #define directive in C preprocessing?
A. To include a header file
B. To define a macro
C. To declare a constant
D. To declare a variable
In C, which directive is used to conditionally include code based on preprocessor macros?
A. #ifdef
B. #ifndef
C. #if
D. #else
Join The Discussion