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: 798 Answers: 3 Posted: 9 years ago

    3 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,

    Next up and on my wrist link as I write this article is link the Apple Watch Ultra. While I have come to like smartwatches over the past few years I have not reconciled with the inability to also wear a dumb watch one I love simply because it's loveable I refuse to double wrist. But for a busy day of meetings exercise or when I'd just like to leave my phone at home and take a phone call on link foot the Apple Watch Ultra is a great tool for the task.



    Top contributors in Uncategorized category

     
    ROMOS
    Answers: 18061 / Questions: 154
    Karma: 1102K
     
    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

    Man88 Media
    Answers: 0 Views: 7 Rating: 0
    mb66spot
    Answers: 0 Views: 7 Rating: 0
    Man88 Phd
    Answers: 0 Views: 11 Rating: 0
    btastic8
    Answers: 0 Views: 11 Rating: 0
    Hbet Icu
    Answers: 0 Views: 11 Rating: 0
    ozanbet
    Answers: 0 Views: 12 Rating: 0
    Xibet Pw
    Answers: 0 Views: 19 Rating: 0
    88aalicom
    Answers: 0 Views: 16 Rating: 0
    > More questions...
    506273
    questions
    749770
    answers
    846501
    users