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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started