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: 726 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: 47270 / Questions: 115
    Karma: 953K
     
    country bumpkin
    Answers: 11322 / Questions: 160
    Karma: 838K
     
    Benthere
    Answers: 2392 / Questions: 30
    Karma: 760K
    > Top contributors chart
    452313
    questions
    719723
    answers
    754242
    users