1
2
3
4
5
6
7
8
9
10
11
| #define FALSE -1
#define TRUE 1
#define NULL 0
main() {
if(NULL)
puts("NULL");
else if(FALSE)
puts("TRUE");
else
puts("FALSE");
} |
#define FALSE -1
#define TRUE 1
#define NULL 0
main() {
if(NULL)
puts("NULL");
else if(FALSE)
puts("TRUE");
else
puts("FALSE");
}
Click here to view the answer
Answer:
TRUE
Explanation:
The input program to the compiler after processing by the preprocessor is,
1
2
3
4
5
6
7
8
| main(){
if(0)
puts("NULL");
else if(-1)
puts("TRUE");
else
puts("FALSE");
} |
main(){
if(0)
puts("NULL");
else if(-1)
puts("TRUE");
else
puts("FALSE");
}
Preprocessor doesn’t replace the values given inside the double quotes. The check by if condition is boolean value false so it goes to else. In second if -1 is boolean value true hence “TRUE” is printed.