Question: Write a recursive function int count_digit(int digit, int numb) that returns the number of occurrences of digit in the decimal representation of numb. digit is
Write a recursive function
int count_digit(int digit, int numb)
that returns the number of occurrences of digit in the decimal representation of numb. digit is an int between zero and nine inclusive. For example, the call count_digit(8, 18488) should return 3, because there are three eights in the decimal representation of 18488. Recall that if num is an integer, then num/10 is the integer part of num divided by ten, while num%10 is the remainder of num divided by ten. These provide a way to split the problem into smaller pieces. All looping in your function must be accomplished with recursion---you may not use any of iteration constructs. You may use a helper function if you like, but none is necessary.
Step by Step Solution
There are 3 Steps involved in it
To write a recursive function countdigitint digit int numb that counts the number of occurrences of ... View full answer
Get step-by-step solutions from verified subject matter experts
