ProgrammingHardHCL · Tech Mahindra pattern

What is printed?

What is printed?
#define IS_EVEN(x) ((x) % 2 == 0)
#define IS_ODD(x) (!IS_EVEN(x))
int main(void) {
    int n = 7;
    printf("%d %d", IS_EVEN(n), IS_ODD(n));
}
  1. A. 0 1
  2. B. 1 0
  3. C. 0 0
  4. D. 1 1

Correct answer: A. 0 1

IS_EVEN(7) expands to (7 % 2 == 0) = (1 == 0) = 0 (false). IS_ODD builds on IS_EVEN by negating it: !0 = 1 (true). So: 0 1.

More C Programming questions

Exams that ask this topic