ProgrammingHardTCS NQT · Wipro

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    printf("%d", 2 * 3 + 4 % 3 == 0 ? 1 : 2);
}
  1. A. 2
  2. B. 1
  3. C. 6
  4. D. 0

Correct answer: A. 2

Multiplication and remainder bind before ==, so 2 * 3 + 4 % 3 is 7, and 7 == 0 is false. The conditional then gives 2.

More C Programming questions

Exams that ask this topic