11.) In a for loop, where is the initialization step typically placed?
A) Before the loop
B) After the loop
C) Within the loop body
D) Initialization is not required in a for loop.
12.) Which control statement is used to exit from a loop or switch-case statement prematurely?
A) continue
B) exit
C) terminate
D) break
13.) Which of the following is true about the “default” case in a switch statement?
A) It is mandatory in every switch statement.
B) It can be placed anywhere in the switch statement.
C) It is executed when no other case matches the expression value.
D) It is used to compare the value of the expression.
14.) The “if-else if-else” ladder allows you to:
A) Execute only the “if” block.
B) Execute any number of “if” blocks.
C) Execute only the first matching block.
D) Execute all the blocks in sequence.
15.) Which loop is best suited for situations where you don’t know in advance how many times the loop needs to execute?
A) for loop
B) while loop
C) do-while loop
D) It’s not possible to determine without additional information.
16.) What is the primary purpose of the “break” statement in a loop?
A) To exit the program.
B) To skip the current iteration of the loop and continue to the next iteration.
C) To terminate the loop and resume execution after the loop.
D) To compare values.
17.) Which control statement is used to execute a block of code if a certain condition is true and a different block if the condition is false?
A) if-else
B) if-else if-else
C) switch-case
D) for loop
18.) The “switch-case” statement is best suited for:
A) Evaluating complex conditions.
B) Evaluating floating-point numbers.
C) Evaluating a single expression against multiple possible values.
D) Evaluating boolean expressions.
19.) Which loop executes the loop body at least once, even if the condition is false?
A) for loop
B) while loop
C) do-while loop
D) switch-case loop
20.) In a “for” loop, what happens if the update statement is missing?
A) The loop will not execute.
B) The loop will enter an infinite loop.
C) The loop will execute only once.
D) The loop will produce a compilation error.