Skip to main content

Section 16.4 Practice: Conditional Compilation

Check Your Understanding Check Your Understanding

1.

What is the output of the following code?
#define DEBUG 1
#include <stdio.h>
int main(void)
{
  int N, i, sum;
  i = 1;
  #if (DEBUG >=2)
    printf("It's a beautiful day! ");
  #elif (DEBUG >=1)
    printf("It's sunny! ");
  #elif (DEBUG >=0)
    printf("Not too bad! ");
  #else
    printf("Huh...! ");
  #endif
}
  • It’s sunny!
  • Correct
  • Huh...!
  • Not quite. Try again!
  • Not too bad!
  • Not quite. Try again!
  • It’s sunny! Not too bad!
  • Not quite. Try again!
  • It’s a beautiful day!
  • Not quite. Try again!
  • It’s a beautiful day! It’s sunny!
  • Not quite. Try again!
  • Not too bad! huh...!
  • Not quite. Try again!