Loop semantics: FOR C := A TO B DO ...
Andrew Koenig
ark at alice.UUCP
Thu Feb 9 23:47:03 AEST 1989
In article <1989Feb8.183945.21485 at sq.uucp>, msb at sq.uucp (Mark Brader) writes:
> if (a <= b) {
> c = a;
> do {
> <Body>
> } while (c++ < b);
> }
> This does what was asked for -- and yes, I tested it. So you might
Even though you tested it, it's wrong. The last time through the loop,
c == b. Thus after exiting from the loop, c == b+1. This violates
the conditions of the problem. (imagine a machine that checks for
integer overflow)
--
--Andrew Koenig
ark at europa.att.com
More information about the Comp.lang.c
mailing list