home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16919 < prev    next >
Encoding:
Internet Message Format  |  1992-11-20  |  1.9 KB

  1. Xref: sparky comp.lang.c:16919 comp.lang.c++:16679 comp.misc:4358
  2. Newsgroups: comp.lang.c,comp.lang.c++,comp.misc
  3. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!udecc.engr.udayton.edu!blackbird.afit.af.mil!cbrooks
  4. From: cbrooks@afit.af.mil (Christopher L Brooks)
  5. Subject: Re: Confused
  6. Message-ID: <1992Nov20.193142.15734@afit.af.mil>
  7. Sender: news@afit.af.mil
  8. Nntp-Posting-Host: scgraph.afit.af.mil
  9. Organization: Air Force Institute of Technology
  10. References: <957@hq.dla.mil>
  11. Date: Fri, 20 Nov 1992 19:31:42 GMT
  12. Lines: 55
  13.  
  14. fhi0055@hq.dla.mil (Marc Poole) writes:
  15.  
  16.  
  17. > The following is a program that I am trying to write.  I can not seem
  18. > how to get the outer loop to work.  The situation is, the inner loop
  19. > will run until it is finished, when it falls through the program should
  20. > prompt for another int input.  If the user inputs 0 then the whole
  21. > program will end.  If the user inputs any other number, the loop will
  22. > continue. 
  23.  
  24. >#include <stdio.h>
  25. >main()
  26. >{
  27. >float answr;
  28. >int fact;
  29. >int count;
  30. >count = 1;
  31. >printf ("This program is designed to print the factoral of a number ");
  32. >printf ("entered by the user.\n");
  33. >printf ("Enter you number: ____\b\b\b\b");
  34. >scanf ("%d",&fact); 
  35.  
  36. >while 
  37.  
  38. Try "while (fact != 0)" here instead.  My compiler won't even accept
  39. the above syntax (while with no argument).
  40.  
  41. >{
  42. >    while (fact > 0)
  43. >       {
  44. >       count = count * fact--;
  45. >       }
  46. >answr = count;
  47. >printf ("%e", answr);
  48. >printf ("\n");
  49. >printf ("Enter another number or 0 to quit: ___\b\b\b");
  50. >}
  51.  
  52.  
  53. >printf ("\n");
  54. >}
  55.  
  56. > I left the while statement in the beginning of the outer loop, because
  57. > that's the loop I am trying to use.  It's the coding for that statement
  58. > I can't figure.  Should scanf come after the first while, with it or is
  59. > while not correct at all?
  60.  
  61. > If anyone can help or steer me in right direction please let me know.
  62.  
  63. > Hints and not answers would be greatly appreciated, explanations would
  64. > be appreciated aslo.
  65.  
  66. Hope this helps.
  67.  
  68. Chris
  69.