Skip to content
Related Articles

Related Articles

Improve Article

C | Macro & Preprocessor | Question 5

  • Difficulty Level : Easy
  • Last Updated : 05 Feb, 2013
Geek Week




#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)

Explanation: The conditional macro #if ISEQUAL(X, 0) is expanded to #if X == 0. After the pre-processing is over, all the undefined macros are initialized with default value 0. Since macro X has not been defined, it is initialized with 0. So, Geeks is printed.

Take a step-up from those “Hello World” programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.
My Personal Notes arrow_drop_up
Recommended Articles
Page :