|
|
Activity:
Question posted: 09 14 2011 15:49:05 +0000,
1 answers, 131 views, last activity
09 14 2011 19:22:19 +0000
|
|
|
|
there is a lot of difference between a for, while and do while loop; For loop seldom checks any condition, and basically there is a counter variable that is iterated, so that a code runs a particular number of times.
while loop always checks a condition, and runs until the condition is true, the loop stops as soon as the condition is false. so here in while loop there can be no fixed number of times that the loop will run, it will run until the condition is true !!! ,upto any number of times(not fixed) although condition can be so set that the loop runs desired number of times!!
in a do while loop the loop runs atleast one time although if a condition is contradictory also!!!
It depend upon the situation, that what loop do u use so that ur code is flexible!!
Hope u get my point !!!
best wishes , NjOy!!
|
|
|
|
|
|
|
|
|
|
