Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!snorkelwacker.mit.edu!ira.uka.de!fauern!faui43.informatik.uni-erlangen.de!prknoerr From: prknoerr@immd4.informatik.uni-erlangen.de (Peter Knoerrich) Newsgroups: comp.lang.pascal Subject: Re: Another TPascal puzzle Keywords: puzzle,pascal Message-ID: <1991Jun27.131736.27167@informatik.uni-erlangen.de> Date: 27 Jun 91 13:17:36 GMT References: <1991Jun26.103834.24736@informatik.uni-erlangen.de> Organization: CSD., University of Erlangen, Germany Lines: 42 prknoerr@immd4.informatik.uni-erlangen.de (Peter Knoerrich) writes: Sorry there actually _IS_ a heavy typing error in the program code, I intended to run the Inner y-loop from 1 to 10! Actually, without trying I would not be able to predict what happened to a loop: "for y:=1 to y do ...". So here is the correct version: >program why_ten? >(* this is an example why even clearly defined scopes can't help > sometimes; better: don't use duplicate variable name as long > as possible *) >var > x,y : byte; >procedure Outer; > var > y : byte; > > procedure Inner; (* show a multiplication table *) > begin > for x:=1 to 10 do begin > for y:=1 to 10 do > (* ^^ this must be a ten! *) > write(x*y:5); > writeln; > end; > end; > begin (* of Outer *) > for y:=1 to 10 do (* 10 linefeeds *) > writeln; > Inner; > end; >begin (* of why_ten? *) > Outer; >end. --- sig? You must be kidding with all those SIGKILLs around on this machine! Peter Knoerrich, email: prknoerr@faui43.informatik.uni-erlangen.de