🎙 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 6 of 10

What does this print? (code)

What does this print?

#include <stdio.h>
int main(void) {
    int a = 5, b;
    b = (a++, a * 2);
    printf("%d %d\n", a, b);
    return 0;
}
  1. A.5 10
  2. B.6 10
  3. C.6 12
  4. D.5 12
Answer & explanation

Correct answer: 6 12

The comma operator runs a++ first (a becomes 6), then the value of the whole expression is a * 2 = 12.

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 →