Algorithms & Flow Control MCQs

Topic-wise practice questions for Problem Solving & Analytical Skills. Test your knowledge, check solutions on demand, and pace your preparation.

Zero-leak answer engine • Rate-limited explanations
Practice in Timed Mode
Q1medium
A school grading system assigns 'A' for ≥ 90, 'B' for ≥ 80, and 'C' for ≥ 70. What is the most efficient control flow structure to determine a single student's grade?
Q2medium
A developer wants to print the numbers 1 through 5. They write:

i = 1
while (i < 5):
    print(i)
    i = i + 1
What is the logical error in this code?
Q3easy
What is the danger of writing an IF statement like this in C/C++/Java?

if (userRole = "Admin") { ... }
Q4hard
(Code Output)

x = 10
if (x > 5):
    if (x == 10):
        print("A")
    print("B")
else:
    print("C")
What will this output?
Q5medium
How many times will the word "Hello" be printed in the following nested loop?

for i from 1 to 4:
    for j from 1 to 3:
        print("Hello")
Q6easy
What happens when a break statement is encountered inside a loop?
Q7hard
(Code Output) Trace the following loop:

sum = 0
for i from 1 to 3:
    sum = sum + i
print(sum)
Q8medium
Look at this SWITCH statement:

color = "Red"
switch (color):
    case "Red":
        print("Stop")
    case "Green":
        print("Go")
In languages like C, Java, or JS, what is printed?
Q9medium
Trace the following algorithm that swaps two variables without a temporary variable:

A = 5
B = 10
A = A + B
B = A - B
A = A - B
What are the final values of A and B?
Q10easy
By definition, an algorithm must possess which of the following characteristics?