Machine-translated by Google. Questions are authored in English.
Top

Discussion

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;
}

 

  • A.Compiler Error
  • B.GeeksQuiz
  • C.MAIN
  • D.main

Answer: B

Correct answer: GeeksQuiz

## is the token-pasting operator. macro(n, a, i, m) substitutes the arguments and joins them in the order m a i n, producing the single token main. So int MAIN() becomes int main(), the program is well formed, and it prints GeeksQuiz.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.