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
Q1easy
What is the output?

int a = 10, b = 20;
int result = (a > b) ? (a + b) : (b - a);
print(result);
Q2easy
When is an if-else if chain more efficient than multiple if statements?
Q3medium
Look at this loop carefully. What is the outcome?

for (double i = 0.0; i != 1.0; i += 0.1) {
    print(i);
}
Q4medium
In a video game, you want a "Gravity" function to run every frame unless the game is "Paused." Which structure is most logical?
Q5medium
What happens when a break statement is executed inside the inner loop of two nested loops?
Q6medium
Trace the output:

for (int i = 0; i < 10; i++) {
    if (i % 3 == 0) continue;
    if (i > 5) break;
    print(i);
}
Q7medium
How many times will "Hello" be printed?

for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 2; j++) {
        if (i == j) continue;
        print("Hello");
    }
}
Q8medium
Which control structure is best suited for implementing a "State Machine" where a variable can be in one of many discrete states?
Q9medium
An algorithm's performance is O(N²). This is most likely caused by which control structure?
Q10medium
How many times will the condition in this while loop be evaluated?

int x = 0;
while (x < 5) {
    x++;
}