1) What is a loop in programming? a) A loop is a condition that terminates the program. b) A loop is a statement that allows a set of instructions to be executed repeatedly. c) A loop is a variable that stores a sequence of values. 2) Which of the following is NOT a type of loop in most programming languages? a) for loop b) if loop c) while loop 3) What is the purpose of a for loop? a) To execute a block of code repeatedly until a condition is met. b) To iterate over a sequence of elements a specific number of times. c) To make decisions based on whether a condition is true or false. 4) In a while loop, when does the condition get checked? a) Before executing the loop body. b) After executing the loop body. c) Both before and after executing the loop body. 5) What does the keyword "break" do in a loop? a) It skips the current iteration and proceeds to the next one. b) It terminates the loop and exits it immediately. c) It reverses the direction of the loop. 6) Which loop is more suitable when you know the number of iterations beforehand? a) for loop b) while loop c) do-while loop 7) What is an infinite loop? a) A loop that executes only once. b) A loop that executes endlessly because its terminating condition is never met. c) A loop that executes with a fixed number of iterations. 8) What does the "continue" statement do in a loop? a) It terminates the loop. b) It skips the rest of the loop body and proceeds to the next iteration. c) It restarts the loop from the beginning. 9) Which loop is guaranteed to execute at least once? a) for loop b) while loop c) do-while loop 10) What is the difference between a while loop and a do-while loop? a) There is no difference; they are two names for the same type of loop. b) In a while loop, the condition is checked before the loop body is executed, while in a do-while loop, the condition is checked after the loop body is executed. c) A while loop iterates over a sequence, while a do-while loop performs a specific action repeatedly.

Leaderboard

Visual style

Options

Switch template

Continue editing: ?