answersLogoWhite

0


Best Answer

A for loop is classified as an iteration statement. A simple example might be...

For x = 1 To 10

'loop body

Next x

The same loop expressed as a while loop (classified as a control flow statement) could be...

x = 0

Do While x < 11

'loop body

x = x + 1

Loop

.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Since there's no loop given, general instructions will have to do. If it's a typical for loop, initialize the variable before the loop. Put the conditional as the condition for the while loop. And the variable change instruction, put at the end of the statement block inside the while loop. And there you go, the for loop is now a while loop.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

While loop:

while (condition)

{

do some stuff

}

Do while loop:

do

{

some stuff

} while (condition)

(This answer has nothing to do with the question.)

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

if-else is not a loop.

but if you want, you can do this:

in: if (expr) statement

out: while (expr) { statement; break; }

of course it has no advantage at all

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you convert a while loop to do-while loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between while dowhile?

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.


List out the differences between while and dowhile statement?

The do ..while loop is executed at least once, whereas the while loop may not be executed even once.


What is unique about a DOWHILE loop?

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.


Is a DOWHILE loop more flexible than a dountil loop?

No, they are equivalient. DO something WHILE condition; does the same thing as DO something UNTIL NOT condition;


What is difference between while and dowhile?

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


What is a dowhile statement in C programming?

"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.


What is the difference between dowhile loop dountil?

A do-while loop checks its termination condition before each iteration, including the first; a do-until checks after each iteration, so that the first iteration occurs before the first check. The C language uses the word "while" for both types of loop, using the placement of the condition to control its timing:C do-while:while (condition) { /* condition checked before first loop iteration */... loop contents}C do-until:do {... loop contents} while (condition); /* condition not checked until after first loop iteration */


How do you convert a while loop to a do loop?

input:while (condition) statementoutput:for (;condition;) statementor, if you mean do-while:do { if (condition) statement } while (condition);


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


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