Open In App

C | Macro & Preprocessor | Question 15

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

Article Tags :