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
There are 100 students in a class. The management keep information in two tables. Those two tables are given like Roll no Name Age 001 ABC 15 002 XYZ 14 and Roll No Subject Marks 001 Math 75 001 Physics 55 002 Math 68 001 Hindi 69 They want the information like this Roll No Name Hindi Physics Math Total 001 ABC 69 55 75 199 002 XYZ 68 74 84 226 And Roll No Suject Highest 001 Math 98 007 Physics 84 021 Hindi 74 All 275 All information is kept in structure in main memory. You have to find last two tables.
Which format specifier is used for printing a pointer value?
What is oops in c++?
Define a nested class.
Explain how we implement exception handling in c++?
Explain static and dynamic memory allocation with an example each.
What is istream c++?
What are namespaces in c++?
What is the use of setprecision in c++?
What is a catch statement?
Can we make any program in c++ without using any header file and what is the shortest program in c++.
What is function prototyping? What are its advantages?
What is a buffer c++?
What is virtual function? Explain with an example
What is setw manipulator in c++?