ProgrammingHardGATE CS · TCS NQT

What is printed? Assume int is 4 bytes.

What is printed? Assume int is 4 bytes.
#include <stdio.h>
int main(void) {
    printf("%d %zu", 1 ? 'A' : 0, sizeof(1 ? 'A' : 0));
}
  1. A. 65 1
  2. B. A 4
  3. C. 65 4
  4. D. 65 0

Correct answer: C. 65 4

The conditional operator's result has type int here, because 'A' is promoted to int in the expression, so the value is 65 and its size is 4. Printing the character would give A.

More C Programming questions

Exams that ask this topic