C | Macro & Preprocessor | Question 14

What is the output of following program?

filter_none

edit
close

play_arrow

link
brightness_4
code

#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


(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



My Personal Notes arrow_drop_up