The goal is to count the frequency of no.s(0,1,2,3,4) and increment all other characters.
Only the default case increments. I have a break statement which I thought would kick back to while which precedes the switch case statement.
I am still trying to figure out how to search for a number - do I look for 0 or '0'?
Thanks in advance for any help on pointing me in the right direction.
int c, nzero, none, ntwo, nthree, nfour, nother;
nzero = none = ntwo = nthree = nfour = nother = 0;
while ((c = getchar()) && c != EOF)
if(c == 0 && isdigit(c))
if(c == 1 && isdigit(c))
if(c == 2 && isdigit(c))
if(c == 3 && isdigit(c))
if(c == 4)
if(isalpha(c) || isdigit(c))
if(c = EOF)
printf("Zero occurs %d times\nOne occurs %d times\nTwo occurs %d times\nThree occurs %d times\nFour occurs %d times\nOther Characters appear %d times\n", nzero,none,ntwo,nthree,nfour,nother);