🎴 Flashcard Mode

C Programming Fundamentals and Standard Specification

Card1 / 25
Mastered0
Review0
QuestionClick to flip

int x = 0;
for ( ; ; )
{
if (x++ == 4)
break;
continue;
}
printf(x=%dn, x);

What will be printed when the sample code above is executed?

AnswerClick to flip back
A
x = 5
💡 Explanation:

The loop uses post-increment (x++), which means the current value is compared first, then x is incremented. When x=4, the condition (x++==4) is true (4==4), then x becomes 5, and the break executes. The printf shows x=5, not x=4, because the increment happens after the comparison.

Change Mode