19.4k views
5 votes
How does a WHILE loop start?

a) while (i <= 10; i++)
b) while (i <= 10)
c) while i = 1 to 10
d) while (i < 10; i++)

User Bumperbox
by
7.1k points

1 Answer

4 votes

Final answer:

The correct way to start a while loop is option b) while (i <= 10), where 'while' initializes the loop and the condition i <= 10 determines when the loop will stop executing.

Step-by-step explanation:

A while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The correct syntax for starting a while loop in languages like C, Java, and JavaScript is b) while (i <= 10). There is no semicolon after the condition in a while loop, and the action of incrementing a variable, like i++, is typically done inside the loop's body, not in the while statement itself.

User Farhad Malekpour
by
9.0k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.