Control Structures MCQs

Topic-wise practice questions for Programming (C++ / Java / Python). Test your knowledge, check solutions on demand, and pace your preparation.

Zero-leak answer engine • Rate-limited explanations
Practice in Timed Mode
Q11easy
What is the "Short-Circuit" effect in the context of an if statement condition?
Q12easy
What will be printed?

int i = 0;
for (; i < 3; i++);
print(i);
Q13medium
Why is while(true) without a break inside usually a critical bug in a standard desktop application?
Q14medium
Trace the output of this C++ snippet:

int n = 1;
label:
print(n);
n++;
if (n <= 3) goto label;
Q15easy
What is the "Dangling Else" problem?
Q16easy
Why is a do-while loop generally preferred over a while loop for displaying a user menu?
Q17easy
What is the final value of x?

int x = 0;
while (x < 10) {
    if (x < 5) x += 2;
    else x += 5;
}
Q18medium
Trace the value of sum:

int sum = 0;
for (int i = 0; i < 5; i++) {
    if (i % 2 == 0) sum += i;
    else if (i == 3) break;
    else sum -= 1;
}
Q19easy
What is the output of the following C++/Java code?

int x = 2;
switch (x) {
    case 1: print("A");
    case 2: print("B");
    case 3: print("C");
    default: print("D");
}