Xref: utzoo comp.lang.modula2:1272 comp.lang.c:16123 Path: 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 In article <1989Feb8.183945.21485@sq.uucp>, msb@sq.uucp (Mark Brader) writes: > if (a <= b) { > c = a; > do { > > } 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