Article View: comp.lang.modula2
Article #4627Re: Loop semantics: FOR C := A TO B DO ...
From: Andrew Koenig
Date: Thu, 09 Feb 1989 13:47
Date: Thu, 09 Feb 1989 13:47
18 lines
961 bytes
961 bytes
In article <1989Feb8.183945.21485@sq.uucp>, msb@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@europa.att.com
Technical Details
Message-ID:
<8891@alice.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!rutgers!att!ulysses!andante!alice!arkReferences:
<763@csd4.milw.wisc.edu> <1989Feb8.183945.21485@sq.uucp>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!rutgers!att!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.modula2,comp.lang.c Subject: Re: Loop semantics: FOR C := A TO B DO ... Message-ID: <8891@alice.UUCP> Date: 9 Feb 89 13:47:03 GMT References: <763@csd4.milw.wisc.edu> <1989Feb8.183945.21485@sq.uucp> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 18