[futurebasic] Re: FOR loop

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 1997 : Group Archive : Group : All Groups

From: PEREIRA CHRISTOPHER A <pereira@...>
Date: Tue, 2 Dec 1997 22:13:42 -0500
> That's interesting.  it makes sense...the second structure is exactly
> what the logic of the FOR loop should be.  If, in the DO UNTIL
> structure, i is initially greater than Y, would C execute the loop or
> just skip it?  I'm C impaired.


Don't worry, all C-programmers are C-impaired.

The FOR loop in C is:

   FOR ( expression 1; expression2; expression 3)
      execute this!

   expression 1 is initialised once at the beginning of the loop
   expression 2 is evaluated at the top of the loop
   expression 3 is loop modifier

   example: for (i=1; i>10; i=i+3)   
   is equivalent to   FOR i=1 to 10 STEP 3 : NEXT i

To answer your question, C would not execute if the initial value were
greater than terminating value. 

   example: for (i=10; i>3; i=i+4)   would not execute