The questions says it all:
...
int ndigit[10];
...//fill in the array with 0s
while((c = getchar()) != EOF)
if(c >= '0' && c <= '9')
++ndigit[c - '0']; //<== unable to understand this part
supposedly, the array stores incoming digit chars from the input stream…
In C, you can do arithmetic on characters using their character codes. So this makes sure that you have a digit, finds out which digit it is (by measuring its difference from zero) and then increments a count in the corresponding position in the array. When it’s done,
ndigit[0]will contain the number of occurrences of'0',ndigit[1]will contain the number of occurrences of'1', and so on.