Computer Science, asked by bhatkifayat783, 7 months ago

What is “While Loop”? Write its syntax?

OR

What is "For Loop"? Write its syntax?​

Answers

Answered by praveenkumarjsr35
1

Answer:

The while loop has the following syntax: while (condition) { // code // so-called "loop body" } While the condition is truthy, the code from the loop body is executed. For instance, the loop below outputs i while i < 3 : let i = 0; while (i < 3) { // shows 0, then 1, then 2 alert( i ); i++; }

Hope it's helpful

Answered by Anonymous
4

\bold{\pink{\fbox{\red{What is “While Loop”? Write its syntax?}}}}

{\boxed{\boxed{\boxed{\boxed{Answer}}}}}

The while loop has the following syntax: while (condition) { // code // so-called "loop body" } While the condition is truthy, the code from the loop body is executed. For instance, the loop below outputs i while i < 3 : let i = 0; while (i < 3) { // shows 0, then 1, then 2 alert( i ); i++; }

\bold{\pink{\fbox{\red{What is “For Loop”? Write its syntax?}}}}

{\boxed{\boxed{\boxed{\boxed{Answer}}}}}

The init step is executed first, and only once. If it is false, the body of the loop does not execute and the flow of control jumps to the next statement just after the 'for' loop. After the body of the 'for' loop executes, the flow of control jumps back up to the increment statement.

Statement 1 sets a variable before the loop starts (int i = 0). Statement 2 defines the condition for the loop to run (i must be less than 5). If the condition is true, the loop will start over again, if it is false, the loop will end.

Hope it's helpful to you all.

Thank you :)

Similar questions