close
    Any problem with this code

    #include<stdio.h>
    /*Counts digits, white numbers, others*/
    main()
    {
        int c, i, nwhite, nother;
        int ndigit[10];
        nwhite=nother=0;
        for(i=0; i<10; ++i)
        ndigit[i]=0;
        while((c=getchar())!=EOF)
        if(c>='0' && c<='9')
        ++ndigit[c-'0'];
        else if(c==' ' || c=='\n' || c=='\t')
        ++nwhite;
        else
        ++nother;
        printf("digits= ");
        for(i=0; i<10; ++i)
        printf("%d ", ndigit[i]);
        printf("\nwhitespace=%d, other=%d\n", nwhite, nother);
    }

    +2  Views: 754 Answers: 2 Posted: 8 years ago

    2 Answers

    No problem that I can see and I've checked it twice.

    slimjimpopo

    try the output for digits. it does'nt give me a reasonable output
    Ducky

    Moderator
    Can't right now. I'll have to leave that for one of our other aka experts.
    sunnyB

    Roy will work it out blindfolded, me, I've got a headache already.
    slimjimpopo

    Thanks anyway. I found out why it outputs the digits in that fromat
    Ducky

    Moderator
    Way to go slim. I knew you could.

    Alright for kids stuff I guess,



    Top contributors in Uncategorized category

     
    ROMOS
    Answers: 18061 / Questions: 154
    Karma: 1101K
     
    Colleen
    Answers: 47269 / Questions: 115
    Karma: 953K
     
    country bumpkin
    Answers: 11322 / Questions: 160
    Karma: 838K
     
    Benthere
    Answers: 2392 / Questions: 30
    Karma: 760K
    > Top contributors chart

    Unanswered Questions

    go88jolieinnyc
    Answers: 0 Views: 2 Rating: 0
    iwinbetcom
    Answers: 0 Views: 7 Rating: 0
    máy rửa xe
    Answers: 0 Views: 10 Rating: 0
    Cinecalidad help
    Answers: 0 Views: 7 Rating: 0
    Cinecalidad help
    Answers: 0 Views: 7 Rating: 0
    Cinecalidad help
    Answers: 0 Views: 7 Rating: 0
    Cinecalidad help
    Answers: 0 Views: 7 Rating: 0
    > More questions...
    466465
    questions
    722243
    answers
    785390
    users