Which of the following statements best describes the functionality of a for…
2025
Which of the following statements best describes the functionality of a for loop in programming?
- A.
It initialises, checks condition, and updates control variable in a single line.
- B.
It continuously executes without checking any condition.
- C.
It allows conditional execution only after running the loop body once.
- D.
It can only be used when the number of iterations is unknown.
Attempted by 104 students.
Show answer & explanation
Correct answer: A
A standard for loop is specifically designed to bring structure and readability to counter-controlled loops. In languages like C, C++, Java, and JavaScript, the loop header contains three distinct parts separated by semicolons, all packed into a single line:
Initialization: Sets up the starting value of the loop control variable (e.g.,
int i = 0).Condition: Tested before every iteration; the loop keeps running as long as this remains true (e.g.,
i < 10).Update: Modifies the control variable after each run of the loop body (e.g.,
i++).