If you are asking how many statements can be a in while loop, there is no maximum. However, from a practical perspective you need to limit the number of statements to a small number to keep the logic understandable.
If you want to execute a statement which is in while loop at least one time you can use do- while loop. this is why because initially first statements will be executed then condition will be checked. but in case of while first condition will be check then statements will be executed
Body of the loop
No. If the loop condition is not satisfied then the loop would not be executed even once. while(condition) { ..... /statements ..... } here,when the condition is true then the statements will be executed. Otherwise they would be skipped without being executed. Only for do.. while loops this execution at least once holds good.
A Do-While loop looks like this: do { loop body } while (condition); and a While loop looks like this: while (condition) { loop body } The main difference is that the loop body is always run once in the Do-While loop, then the condition is checked to see if the loop should keep running. In a While loop, the condition is checked first, and it will not run the loop body at all if the condition is false.
The control structures used in java script are if-statement, for-loop, for-in loop, while loop,do-while loop, switch-statement, with-statement. try-catch-finally statements.
While: If we can use while statement it will check the condition then proceed further loop statement.DoWhile: If we use dowhile, first execute loop statement then check the condition.
The do ..while loop is executed at least once, whereas the while loop may not be executed even once.
A DO-WHILE loop will always execute at least one iteration of the loop body. This is because the condition that controls the loop comes at the end of the loop, rather than at the beginning as per a WHILE or FOR loop.
No, they are equivalient. DO something WHILE condition; does the same thing as DO something UNTIL NOT condition;
the test condition will be checked first after wards the body of the loop will be excuted in while statement and the the do while statement represented the body of the loop will be executed first and then the test condition will checked next
"do statement while (...);" is a loop which does at least one iteration even if the condition after while is false. When, for instance, "while(...) statement" does not iterate at all if the condition after while is false.
These statements are equal parts of the language, none of them if the 'better' or the 'older'.
If you want to execute a statement which is in while loop at least one time you can use do- while loop. this is why because initially first statements will be executed then condition will be checked. but in case of while first condition will be check then statements will be executed
Body of the loop
No. If the loop condition is not satisfied then the loop would not be executed even once. while(condition) { ..... /statements ..... } here,when the condition is true then the statements will be executed. Otherwise they would be skipped without being executed. Only for do.. while loops this execution at least once holds good.
A Do-While loop looks like this: do { loop body } while (condition); and a While loop looks like this: while (condition) { loop body } The main difference is that the loop body is always run once in the Do-While loop, then the condition is checked to see if the loop should keep running. In a While loop, the condition is checked first, and it will not run the loop body at all if the condition is false.
The control structures used in java script are if-statement, for-loop, for-in loop, while loop,do-while loop, switch-statement, with-statement. try-catch-finally statements.