QUESTION IMAGE
Question
which general while loop definition is written correctly? a while (x is true) { // code } b if (i<5) { //code } c while (var 1 = 0; 1 < count; 1++) { //code } d while (condition) { //code }
A while - loop in programming is used to execute a block of code as long as a specified condition is true. Option B is an if - statement, not a while - loop. Option C has incorrect syntax for a while - loop (semicolon - separated expressions are for for - loops in some languages). Option A has an incorrect way of writing a condition in most programming languages (should be a boolean expression like x == true in some languages). Option D is a general correct form where a condition is used to control the loop.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
D. while (condition) {
//code
}