[futurebasic] Re: FOR loop

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

From: Mike Friedman <friedo@...>
Date: Tue, 2 Dec 1997 19:07:49 -0500 (EST)

On Tue, 2 Dec 1997, PEREIRA CHRISTOPHER A wrote:

> I was told in my 'Introduction to C programming' class that the FOR-NEXT
> structure is executed as a special case of the DO-UNTIL structure.
> 
> FOR i = X to Y STEP S
>    execute this!
> NEXT i
> 
> is really executed as ...
> 
> i = X
> DO
>    execute this!
>    IF S >= 0 THEN INC(i) ELSE DEC(i)
> UNTIL i > Y
> 
> My instructor _could_ have been wrong ...
> 
> _Chris
> 

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.

- Mike