Multiple choice

What will be the output of the following function?

#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts(NULL); else if(FALSE) puts(TRUE); else puts(FALSE); }

  1. NULL

  2. TRUE

  3. FALSE

  4. No

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The code skips the first block because NULL is 0 (false). It enters the 'else if' block because FALSE is defined as -1, which is non-zero and thus true in C, resulting in the output 'TRUE'.