ProgrammingHardTCS NQT · Wipro

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    char c = 'a';
    printf("%d", c++ == 'a' && c == 'b');
}
  1. A. 1
  2. B. 0
  3. C. 2
  4. D. 3

Correct answer: A. 1

c++ yields 'a' in the first test and then c becomes 'b', so both operands of && are true. The second test sees the incremented value.

More C Programming questions

Exams that ask this topic