Re: Why is it wrong??(About n!)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bart van Ingen Schenau

    Re: Why is it wrong??(About n!)

    On Oct 30, 12:20 pm, upyzl <zj262...@163.c omwrote:
    Now I change it into:
    >
    <snip - code>
    I know that now my only problem is "while ( ( nonnega_int =
    getchar() ) != EOF )"
    but I want to loop as what user want.
    Should I add "int loop" or?
    >
    I must say, I haven't studied about "goto" and of course I don't know
    how to use it.
    In fact, now I only know use "while ( ( XXXX = getchar() ) != EOF )"
    to control loop times,
    and I think it should work.
    >
    What should I do?
    Change your loop to look like this:

    // scanf line before the loop removed

    while (scanf("%d", &nonnega_int ) == 1)
    {
    // code to calculate factorial
    }

    This will loop around as long as the user enters valid numbers
    (integers).

    Bart v Ingen Schenau
Working...