[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Difference between for and while loop



This is the way it was explained to me.

A FOR loop is usually used to execute a routine or instruction(s) a
fixed number of times, 'fixed' meaning that going into the loop, you
already know how many iterations will be made.  The FOR loop should
also be used when you know that you will be executing the contents of the loop at least once.

The WHILE loop is a conditional operation. Use it in situations where execution of the contents of the loop is dependent on some condition you define. A WHILE loop may execute any number of times or not at all,
obviously depending on the condition and whether your WHILE statement is
before or after the contents of the loop (WHILE/DO OR WHILE DO/UNTIL).

I'm sure the readers who program for living can provide more useful detail on this.



( CAUTION:  FOR and WHILE statements embedded in windows programs may
  require a separate license ).


tm.

raja kumar wrote:



Sir,


    could u tell me the all the differences between FOR and WHILE loops
please..

thanking u sir,

raja kumar




_________________________________________________________________
Windows Server 2003. Do more with less. http://www.msn.co.in/computing/winsvr2003/ Upgrade now!








Reply to: