![]() |
| ||
| Loops Hi, Fairly new to java and programming. Could anyone explain the difference between a for loop and a do while loop in relation to writing a program and typing in numbers and displaying the total. Thanks |
| ||
| Re: Loops A for-loop is typically used when the number of passes through the loop is known in advance. A while loop is typically used when the number of passes is NOT known in advance. A do-while loop is rarely used but can be useful if the loop is known to have to run at least once and the total number of runs isn't known (or at least not known before the end of that first run). |
| ||
| Re: Loops Quote:
yea just want to add on. which loop you use depends on what you want to do. As for while and do while loop , the concept is almost the same, it depends on ur preference. |
| ||
| Re: Loops Quote:
for loop is evaluate up to the condition is false. whereas do-while loop is evaluate once eventhough the condition is false. |
| All times are GMT -4. The time now is 10:34 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC