Consider the following recursive function:
int func (int arg)
{
if (arg % 2 != 0)
return func(arg - 1);
if (arg
return 1;
return func(arg/2) + 1;
}
a. Is there a value of arg that causes an infinite recursion? If so, what
is it?
b. Suppose that the function func is part of a program whose main
function is as follows. How many function calls are made to func
when the program is executed?
int main(void)
printf("The value is %d\n", func(10));
c. What value is output by the program?
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here