What valid values can be passed as parameters to the


1. Consider the following recursive function.

int mystery(int number)
{
if(number == 0)
return number;
else
return(number + mystery(number - 1));
}

a. Identify the base case.

b. Identify the general case.

c. What valid values can be passed as parameters to the function mystery?

d. If mystery(0) is a valid call, what is its value? If not, explain why.

e. If mystery(5) is a valid call, what is its value? If not, explain why.

f. If mystery(-3) is a valid call, what is its value? If not, explain why.

2. Consider the following recursive function:

void funcRec(int u, char v)
{
if(u == 0)
cout<else if(u == 1)
cout<(static_cast(v) + 1);
else
funcRec(u - 1, v);
}

a. Identify the base case.

b. Identify the general case.

c. What is the output of the following statement? funcRec(5, 'A');

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: What valid values can be passed as parameters to the
Reference No:- TGS01247544

Now Priced at $20 (50% Discount)

Recommended (92%)

Rated (4.4/5)