answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: What is wrong with the following Do While Loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How is a while loop different from a do until loop in gml?

In any programming language, a "while" loop and a "do until" loop are the same except for 1 difference. In order to enter a while loop, the condition must always be true. But in a do until loop, if the condition was false, the block of code inside the loop will always be ran at least once. Example: while (false) { // code here } in this example, the code inside the while loop will never run, but in the following example: do { //code here } until(false) although the condition is false, the code will be run 1 single time and the exists the loop.


Compare Do-While with While Statements?

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.


What is difference between for loop and do-while loop?

The do loop is similar to the forloop, except that the expression is not evaluated until after the do loop's code is executed. Therefore the code in a do loop is guaranteed to execute at least once. The following shows a do loop in action: do { System.out.println("Inside do while loop"); } while(false); The System.out.println() statement will print once, even though the expression evaluates to false. Remember, the do loop will always run the code in the loop body at least once. Be sure to note the use of the semicolon at the end of the while expression.


What is a loop type?

A Loop is a programming language construct that instructs the processor to repeat a sequence of operations a number of times until a specific condition is reached. There are different types of loops. They are: * for loop * while loop * do while loop


Why you need a for loop when you have already while loop or do while loop?

We need a for loop because the while and do-while loops do not make use of a control variable. Although you can implement a counter inside a while or do-while loop, the use of a control variable is not as self-evident as it is in a for loop. Aside from the use of a control variable, a for loop is largely the same as a while loop. However, it is quite different to a do-while loop, which always executes at least one iteration of the loop before evaluating the conditional expression. In a for and while loop, the conditional expression is always evaluated before entering the loop, which may result in the loop not executing at all.

Related questions

Where do you get loop the loop straws?

C, for loops, while loops, and do while loops are control structures forFor example, the following programs are functionally identical: While loop


Turning a while loop to a for loop?

A for loop is just a while loop with a built-in counter. For example, the following programs are functionally identical: While loop: int counter = 0; while(counter < 10) { printf("counter = %d\n", counter); counter++; } For loop: for(int counter = 0; counter < 10; counter++) { printf("counter = %d\n", counter); }


The Do-While loop is what type of loop?

The do loop is similar to the while loop, except that the expression is not evaluated until after the do loop's code is executed. Therefore the code in a do loop is guaranteed to execute at least once. The following shows a do loop in action: do { System.out.println("Inside do while loop"); } while(false); The System.out.println() statement will print once, even though the expression evaluates to false. Remember, the do loop will always run the code in the loop body at least once. Be sure to note the use of the semicolon at the end of the while expression.


What is the purpose of wend statement in while loop in gw-basic?

While--wend statement is used to execute a loop until a given condition is true.if the condition is false the loop ends and the program continous to the line following eend.


What is a nested loop in java?

A nested loop is a (inner) loop that appears in the loop body of another (outer) loop. The inner or outer loop can be any type: while, do while, or for. For example, the inner loop can be a while loop while an outer loop can be a for loop.


What are the similarities of while loop and a do while loop?

They both loop


What is meant by while looping?

A "While" loop is a part of computer programming. The logic is "while this condition is true, do the following commands and repeat". By default this will repeat forever creating a "loop" in logic. To stop looping you have to include a command that will change the original condition inside the loop.


How is a while loop different from a do until loop in gml?

In any programming language, a "while" loop and a "do until" loop are the same except for 1 difference. In order to enter a while loop, the condition must always be true. But in a do until loop, if the condition was false, the block of code inside the loop will always be ran at least once. Example: while (false) { // code here } in this example, the code inside the while loop will never run, but in the following example: do { //code here } until(false) although the condition is false, the code will be run 1 single time and the exists the loop.


Compare Do-While with While Statements?

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 while loop is a type of loop?

Is loop


What is difference between for loop and do-while loop?

The do loop is similar to the forloop, except that the expression is not evaluated until after the do loop's code is executed. Therefore the code in a do loop is guaranteed to execute at least once. The following shows a do loop in action: do { System.out.println("Inside do while loop"); } while(false); The System.out.println() statement will print once, even though the expression evaluates to false. Remember, the do loop will always run the code in the loop body at least once. Be sure to note the use of the semicolon at the end of the while expression.


What is a loop type?

A Loop is a programming language construct that instructs the processor to repeat a sequence of operations a number of times until a specific condition is reached. There are different types of loops. They are: * for loop * while loop * do while loop