39.7k views
0 votes
Which general while loop definition is written correctly?

A) while (condition) { // loop body }
B) loop (condition) { // loop body }
C) when (condition) { // loop body }
D) if (condition) { // loop body }

User Ubalo
by
7.4k points

1 Answer

4 votes

Final answer:

The correct definition of a while loop is option A) while (condition) { // loop body }, which allows for repeated execution of code as long as the given condition is true.

Step-by-step explanation:

The while loop is a control flow statement in programming that allows code to be executed repeatedly based on a given boolean condition. The correct syntax for a while loop in most programming languages such as C, C++, Java, and Python is option A) while (condition) { // loop body }. This loop will continue to execute the statements within the loop body as long as the condition remains true. Options B), C), and D) do not represent the correct syntax for a while loop.

User Gnlogic
by
8.0k points

No related questions found