C | Macro & Preprocessor | Question 14
What is the output of following program?
#include <stdio.h> #define macro(n, a, i, m) m##a##i##n #define MAIN macro(n, a, i, m) int MAIN() { printf("GeeksQuiz"); return 0; } |
chevron_right
filter_none
(A) Compiler Error
(B) GeeksQuiz
(C) MAIN
(D) main
Answer: (B)
Explanation: The program has a preprocessor that replaces “MAIN” with “macro(n, a, i, m)”. The line “macro(n, a, i, m)” is again replaced by main. The key thing to note is token pasting operator ## which concatenates parameters to macro.
Quiz of this Question
Recommended Posts:
- C | Macro & Preprocessor | Question 15
- C | Macro & Preprocessor | Question 9
- C | Macro & Preprocessor | Question 5
- C | Macro & Preprocessor | Question 12
- C | Macro & Preprocessor | Question 13
- C | Macro & Preprocessor | Question 11
- C | Macro & Preprocessor | Question 10
- C | Macro & Preprocessor | Question 7
- C | Macro & Preprocessor | Question 4
- C | Macro & Preprocessor | Question 14
- C | Macro & Preprocessor | Question 1
- C | Macro & Preprocessor | Question 8
- C | Macro & Preprocessor | Question 6
- C | Macro & Preprocessor | Question 2
- The OFFSETOF() macro



