Evaluate:
int fn(int v)
{
if(v==1 || v==0)
return 1;
if(v%2==0)
return fn(v/2)+2;
else
return fn(v-1)+3;
}
for fn(7);

a) 10
b) 11
c) 1

Answer Posted / babita sharma

The answer would be
b.

11 Its teh recursive function.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is c++ still popular?

589


What is a driver program?

635


Will a C compiler always compile C++ code a) Yes b) No c) Only optimized compilers

617


What is recursion?

663


What is dev c++ used for?

607






Why do we use iterators?

624


Will this c++ program execute or not?

609


What is c++ programming language?

582


Why struct is used in c++?

624


What is while loops?

619


Why do we need function?

604


Write a C++ Program to check whether a number is prime number or not?

638


Can malloc be used in c++?

572


What is binary search in c++?

570


What does scope resolution operator do?

605