1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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