C | Macro & Preprocessor | Question 13

Output of following C program?

filter_none

edit
close

play_arrow

link
brightness_4
code

#include<stdio.h>
#define max abc
#define abc 100
  
int main()
{
    printf("maximum is %d", max);
    return 0;
}

chevron_right


(A) maximum is 100
(B) abcimum is 100
(C) 100imum is 100
(D) abcimum is abc



Answer: (A)

Explanation: After pre-processing, the source code becomes:

filter_none

edit
close

play_arrow

link
brightness_4
code

int main()
{
    printf("maximum is %d", 100);
    return 0;
}

chevron_right


The “max” in maximum is not a token, so it doesn’t match with max while pre-processing.
So, option (A) is correct.

Quiz of this Question



My Personal Notes arrow_drop_up

Improved By : Tapaj