Skip to content
Related Articles

Related Articles

C | Macro & Preprocessor | Question 15
  • Difficulty Level : Medium
  • Last Updated : 05 Nov, 2020

What is the output for the following code snippet?




#include<stdio.h>
#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
Recommended Articles
Page :