Forum : Practical applications for: for, do and do while loops?
Brief description  about Online courses   join in Online courses
View Avraham  Venismach 's Profile

Practical applications for: for, do and do while loops?

Hi Everybody,

Could show me some practical applications for: for, do and do while loops and point out the main differences and why I would use one over another?

Thank you!
Asked by Avraham Venismach | Feb 4, 2010 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
hi Avraham,

below is the example of for loop , while loop, and do while loop.


Synext for for loop:

for(start; end point;increment)


for(i=0;i<10;i++)


here in for loop,

start is the postion from where loop will start,

like i=0;

end point is that where loop has to stop;

i<10;


and increment is the next iteration of the loop.
i++


now while loop;

synatx:

start;
while(end)
{
increment;
}


i=0;
while(i<10)
{
i++;
}

while loop is work like for loop; but diffrence is: in while loop we have start end pont and increment in diffrent position;


do- while loop:

syntax:

start;
do{
increment;
}
end;

do while loop is just opposit to the while loop, in case of do while loop, loop will execult one either condition match or not.
Feb 5, 2010