Skip to content
Related Articles
Open in App
Not now

Related Articles

C | Macro & Preprocessor | Question 15

Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 05 Nov, 2020
Improve Article
Save Article

What is the output for the following code snippet?

#define A -B
#define B -C
#define C 5
int main()
  printf("The value of A is %d\n", A); 
  return 0;

This question is contributed by Aastha Anand.
(A) The value of A is 4
(B) The value of A is 5
(C) Compilation Error
(D) Runtime Error

Answer: (B)

Explanation: Value of A is replaced by -B, the value of B is replaced by -C which becomes -(-C) then the value of C is replaced by 5 which results to -(-5) which is equivalent to 5. So A is replaced by 5.

Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!