Question: 2 . Recursion ( code ) Be able to identify the following for a recursive function, such as the one shown below: a . How

2. Recursion (code) Be able to identify the following for a recursive function, such as the one shown below:
a. How many recursive calls are made to the function counter() in the example below?
b. What is the output?
c. Look at each statement in the function definition and note what each statements significance is in recursion (you can disregard the cout statements, but everything else is needed here.)
d.(Hint: your answers from #1 should connect to your answers in part c of this problem)
#include
using namespace std;
void counter(int num){
if (num ==0) cout << num <<"";
else {
cout << num <<""; counter(num -5);
}
}
int main(){
counter(45);
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!