home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:16919 comp.lang.c++:16679 comp.misc:4358
- Newsgroups: comp.lang.c,comp.lang.c++,comp.misc
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!udecc.engr.udayton.edu!blackbird.afit.af.mil!cbrooks
- From: cbrooks@afit.af.mil (Christopher L Brooks)
- Subject: Re: Confused
- Message-ID: <1992Nov20.193142.15734@afit.af.mil>
- Sender: news@afit.af.mil
- Nntp-Posting-Host: scgraph.afit.af.mil
- Organization: Air Force Institute of Technology
- References: <957@hq.dla.mil>
- Date: Fri, 20 Nov 1992 19:31:42 GMT
- Lines: 55
-
- fhi0055@hq.dla.mil (Marc Poole) writes:
-
-
- > The following is a program that I am trying to write. I can not seem
- > how to get the outer loop to work. The situation is, the inner loop
- > will run until it is finished, when it falls through the program should
- > prompt for another int input. If the user inputs 0 then the whole
- > program will end. If the user inputs any other number, the loop will
- > continue.
-
- >#include <stdio.h>
- >main()
- >{
- >float answr;
- >int fact;
- >int count;
- >count = 1;
- >printf ("This program is designed to print the factoral of a number ");
- >printf ("entered by the user.\n");
- >printf ("Enter you number: ____\b\b\b\b");
- >scanf ("%d",&fact);
-
- >while
-
- Try "while (fact != 0)" here instead. My compiler won't even accept
- the above syntax (while with no argument).
-
- >{
- > while (fact > 0)
- > {
- > count = count * fact--;
- > }
- >answr = count;
- >printf ("%e", answr);
- >printf ("\n");
- >printf ("Enter another number or 0 to quit: ___\b\b\b");
- >}
-
-
- >printf ("\n");
- >}
-
- > I left the while statement in the beginning of the outer loop, because
- > that's the loop I am trying to use. It's the coding for that statement
- > I can't figure. Should scanf come after the first while, with it or is
- > while not correct at all?
-
- > If anyone can help or steer me in right direction please let me know.
-
- > Hints and not answers would be greatly appreciated, explanations would
- > be appreciated aslo.
-
- Hope this helps.
-
- Chris
-