Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site sequent.UUCP Path: utzoo!watmath!clyde!floyd!vax135!cornell!uw-beaver!tektronix!ogcvax!sequent!merlyn From: merlyn@sequent.UUCP Newsgroups: net.lang.c Subject: Re: little quiz (SPOILER... don't read if you don't want the answer) Message-ID: <436@sequent.UUCP> Date: Thu, 22-Mar-84 13:15:51 EST Article-I.D.: sequent.436 Posted: Thu Mar 22 13:15:51 1984 Date-Received: Sun, 25-Mar-84 10:16:07 EST References: <9031@arizona.UUCP> Organization: Sequent Computer Systems, Portland Lines: 39 >>>>While we are discussing C, how many people believe that >>>> >>>> for (initial; test; update) statement; >>>> >>>>is ALWAYS equivalent to >>>> >>>> initial; >>>> while (test) { >>>> statement; >>>> update; >>>> } >>>> >>>>how many people can cite the exception to the above rule? (ie, one >>>>clearcut case where they produce different results). One that comes to mind immediately is the use of "continue" within "statement". For the for loop, continue makes "update" happen, where in the while loop continue doesn't. For example, this statement: for (i=1; i<=10; i++) continue; eventually exits (after 10 iterations), where: i=1; while (i<=10) { continue; i++; } doesn't. Randal L. Schwartz, esq. Sequent Computer Systems, Inc. UUCP: ...!tektronix!ogcvax!sequent!merlyn (official legendary sorcerer of the 1984 Summer Olympics) BELL: (503)626-5700 Original Material (C) 1984 by Randal L. Schwartz [ALL RIGHTS RESERVED]