Govt Exams
A do-while loop executes the body at least once before checking the condition. A while loop checks the condition first, so it may not execute at all.
The 'break' statement is used to exit or terminate a loop immediately. 'continue' skips the current iteration, 'exit' terminates the entire program.
continue is the C keyword that jumps to the next iteration of the loop.
goto transfers program control to a labeled location, though it's discouraged for code readability.
Since 5 > 3 is true, the ternary operator returns 10, so x = 10.
break terminates the loop entirely, while continue jumps to the next iteration without executing remaining statements.
for (int i = 0; i < 3; i++)
printf("%d ", i);
The loop runs from i=0 to i=2 (i < 3), printing '0 1 2 '.
foreach is not a standard C control flow statement. C has if-else, switch, for, while, do-while, and goto.
int x = 5;
if (x > 3)
printf("A");
else
printf("B");
Since x = 5 and 5 > 3 is true, the if block executes and prints 'A'.
The 'const' keyword creates a read-only variable. Once initialized, attempting to modify a const variable results in a compilation error (error: assignment of read-only variable). This is enforced at compile-time, not runtime.