bug with scanf for character

Discussion in 'C' started by wantai, Aug 28, 2010.

  1. wantai

    wantai New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello guys,

    I am new here. I have been practicing programming in C as I am going back to school. The program below is supposed to be really simple. It would help you calculate the factorial of a number. But I don't know why I can't get the scanf function for the character input to work. Any help will be greatly appreciated.

    Thanks,

    Michael





    #include
    int main (void)
    {
    int input, i, output;
    char yes;

    printf("Welcome to the factorial calculator.\n");
    yes='y';
    while(yes=='y')
    {
    printf("Input a non-negative number:");
    scanf("%d", &input);

    while(input
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice