🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: C Output Questions: all 10 questions

Quiz: C Output Questions · Question 2 of 10

What does this print? (code)

What does this print?

#include <stdio.h>
int main(void) {
    int i = 1;
    if (i-- && i++) printf("A");
    printf("%d", i);
    return 0;
}
  1. A.A1
  2. B.A0
  3. C.1
  4. D.0
Answer & explanation

Correct answer: 1

i-- gives 1 (true) and i becomes 0; then i++ gives 0 (false), so "A" is not printed, and i becomes 1.

Can you get the rest right without peeking?

Take the timed Quiz: C Output Questions quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →