What is the output of the following code fragment?
int f1(int x, int y)
{
if(x<0 || y<0)
return x-y;
else
return f1(x-1,y) + f1(x,y-1);
}
int main()
{
cout << f1(2,1)<
}
a. 0
b. -1
c. 5
d. -5
c. 5
Computer Science & Information Technology
You might also like to view...
A(n) ______ is a tree in which each internal node has either two or three children, and all leaves are at the same level.
a) red-black tree b) 2-3 tree c) 2-3-4 tree d) AVL tree
Computer Science & Information Technology
What is the value of a after execution of the following code?
int a = 10; for (int ctr = 0; ctr < 4; ctr++) a = a – 1; a = a + 3; a) 8 b) 9 c) 18 d) 20
Computer Science & Information Technology