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

Discussion

#include <stdio.h>
#define ISEQUAL(X, Y) X == Y
int main()
{
    #if ISEQUAL(X, 0)
        printf("Geeks");
    #else
        printf("Quiz");
    #endif
    return 0;
}

Output of the above program?

  • A.Geeks
  • B.Quiz
  • C.Any of Geeks or Quiz
  • D.Compile time error

Answer: A

Correct answer: Geeks

The macro expands to X == 0, and inside a #if the undefined identifier X becomes 0. The condition is therefore 0 == 0, which is true, so printf("Geeks") is the line that survives preprocessing.

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

Post your comment

Please log in or register to post a comment.