Consider the following C functions.
int tob (int b, int* arr){ | int pp(int a, int b) { |
The value returned by pp(3,4) is ______.
Correct Answer:
81
Solution:
pp(3, 4) means a = 3, b = 4
arr (initially contain garbage values)
tot = 1 (initially)
ex = 3
len = tob (4, arr)
In tob(4, arr), b = 4
when i = 0, a[0] = 0
when i = 1, a[1] = 0
when i = 2, a[2] = 1
when i = 3 loop breaks and return
len = 3
Now, In pp(3, 4)
when i = 0, ex = 3*3 = 9
when i = 1, ex = 9*9 = 81
when i = 2, tot = 1*81 = 81 and ex = 81*81 = 6561
return 81