Other contributors have said "Diffrence between do while and for loop in c?" is the same question as "What are the differences between Do While and For loops in C?" If you believe that these are not asking the same thing and should be answered differently, click here

What are the differences between Do While and For loops in C?

Answer:

In short, a for loop declares an variable and assigns it a value, has an argument, and has an update. A while loop only has an argument.

More Detail...

in C++, which is very close to C an example while loop is;

while(i<3) { do the following; }

a for loop is

for(int i=0; i<5; i++) { do the following; }

In a while loop, it will do 'do the following;' then check and see if the argument is still true (in this case is i<3). If the argument is not true then the while loop ends and will continue to execute the rest of the code

In a for loop, an integer is delcared and give a value ( int i which is equal to 0). It will then check the argument (i<5) if the argument it true will do 'do the following;' THEN do the update value (which is i++) then checks then repeats the process.

First answer by Paintballkev812. Last edit by Paintballkev812. Contributor trust: 8 [recommend contributor recommended]. Question popularity: 1 [recommend question].