.
int NumDigCofA(int A, int C) { if (A<=0 || C<0 || C>9) return -1; int count=0; while (A>0) { if (A%10==C) count++; A/=10; } return count; }