Re: Difference between for and while loop
On Fre, 18 Apr 2003 at 12:30 (-0700), Craig Dickson wrote:
> Jan Trippler wrote:
> > But thers's no way to prevent the first execution of the loop body.
> > The stop condition (even if it's missing) is checked at the _end_ of
> > first execution. You can leave the body empty or use a *break* to
> > get out of the loop, but that has nothing to do with the definition
> > of the for loop.
> What? That's completely wrong. The test in a for loop in C in checked at
> the TOP of the loop, before the first execution of the body.
*argl*, yes, you're right. I didn't test it - there must have been a
*long time ago learned fact* (for a language I don't remember)
stayed in my brain - firmware update needed ;-)
> I though your recursion examples were unnecessarily complex. A simple
> factorial or Fibonacci sequence function would have demonstrated
> recursion quite adequately with a fraction of the code.
Oh, these examples are in my mind at a top rank because I often have
to do with _such_ problems. I never needed Fibonacci sequences or
factorials in my job but I have to read and process numbers of files