What will be the output of the following C code? [code]#include<stdio.h> #define max 100 main() { #ifdef max printf("hello"); }[/code]

Alvin Le

Member
What will be the output of the following C code?
Code:
#include<stdio.h>
#define max 100
main()
{
    #ifdef max
    printf("hello");
}
A. 100
B. hello
C. “hello”
D. error
 
Answer: d
Explanation: The code shown above results in an error. This is because the preprocessor #endif is missing in the above code. If the identifier is defined, then the statements following #ifdef are executed till #endif is encountered.
 

Tìm kiếm

Back
Top