programming challenge (silly)

Gordon Cross crossgl at ingr.com
Fri Mar 10 08:24:55 AEST 1989


In article <6619 at saturn.ucsc.edu> kjell at 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 at ingr.com        mine and not those
Madison, AL 35758        MA BELL:   (205) 772-7842          of my employer."



More information about the Comp.lang.c mailing list