Skip to content
Related Articles

Related Articles

C Quiz – 110 | Question 1
  • Difficulty Level : Basic
  • Last Updated : 24 Oct, 2015
GeeksforGeeks - Summer Carnival Banner

Suppose someone writes increment macro (i.e. which increments the value by one) in following ways:

#define INC1(a) ((a)+1)
#define INC2 (a) ((a)+1)
#define INC3( a ) (( a ) + 1)
#define INC4 ( a ) (( a ) + 1)

Pick the correct statement for the above macros.
(A) Only INC1 is correct.
(B) All (i.e. INC1, INC2, INC3 and INC4) are correct.
(C) Only INC1 and INC3 are correct.
(D) Only INC1 and INC2 are correct.

Answer: (C)

Explanation: In C, for macros with arguments, there can’t be any space between macro name and open parenthesis. That’s why only INC1 and INC3 are correct. Basically, “#define INC2 (a) ((a)+1)” results in “INC2” expansion to “(a) ((a)+1)” which is not the desired expansion.

Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :