Multiple choice technology programming languages

In a ‘for’ loop, what section of the loop is not included in the parentheses after “for” ?

  1. Initialization

  2. Loop Body

  3. Test statement

  4. Update

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In a for loop, the parentheses contain initialization, test condition, and update sections separated by semicolons. The loop body (the code to execute) is outside these parentheses, typically in curly braces. Options A, C, and D are all part of the for loop declaration within the parentheses.

AI explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Initialization - This option is incorrect because the initialization section is included in the parentheses after "for". It is typically used to initialize a counter variable.

Option B) Loop Body - This option is correct. The loop body is not included in the parentheses after "for". It is the block of code that is executed repeatedly as long as the test statement is true.

Option C) Test statement - This option is incorrect because the test statement is included in the parentheses after "for". It is used to check the condition for executing the loop body.

Option D) Update - This option is incorrect because the update section is included in the parentheses after "for". It is used to update the counter variable after each iteration of the loop.

The correct answer is B) Loop Body. This option is correct because the loop body is not included in the parentheses after "for".