Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!ingr!crossgl From: crossgl@ingr.com (Gordon Cross) Newsgroups: comp.lang.c Subject: Re: programming challenge (silly) Message-ID: <4344@ingr.com> Date: 9 Mar 89 22:24:55 GMT References: <2102@jasper.UUCP> <9789@smoke.BRL.MIL> <3115@homxb.ATT.COM> <6619@saturn.ucsc.edu> Reply-To: crossgl@ingr.UUCP (Gordon Cross) Distribution: na Organization: Intergraph Corp. Huntsville, Al Lines: 20 In article <6619@saturn.ucsc.edu> kjell@saturn.ucsc.edu (Kjell Post) writes: > >I have 91 now but am not sure about portability of main(n,m) and printf. > >main(n,m){scanf("%d\n",&m);while(m>1&m<10)n*=m--; >printf(m-1?"error\n":"answer is %d\n",n);} Interesting BUT: this does NOT behave the same way as the original program in all cases!! Try running the original and your versions using: silly 5 2 The original yields: answer is 2 Yours yields: answer is 4 -- Gordon Cross UUCP: uunet!ingr!crossgl "all opinions are 111 Westminister Way INTERNET: crossgl@ingr.com mine and not those Madison, AL 35758 MA BELL: (205) 772-7842 of my employer."