How does a "while" loop start?

  1. while (i<=10)

  2. while (i<=10;i++)

  3. while i=1 to 10

  4. while (i=0;i<=10;i++)


Correct Option: A

AI Explanation

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

Option A) while (i<=10) - This option is correct because it starts the "while" loop with the condition that the loop will continue as long as the variable "i" is less than or equal to 10.

Option B) while (i<=10;i++) - This option is incorrect because it uses the semicolon (;) inside the parentheses, which is not the correct syntax for a "while" loop.

Option C) while i=1 to 10 - This option is incorrect because it uses the assignment operator (=) instead of the comparison operator (<=) to set the condition for the loop.

Option D) while (i=0;i<=10;i++) - This option is incorrect because it uses the assignment operator (=) instead of the comparison operator (<=) to set the initial value of "i" and the condition for the loop.

The correct answer is Option A. This option is correct because it correctly starts the "while" loop with the condition that the loop will continue as long as the variable "i" is less than or equal to 10.

Find more quizzes: