Computer Sciences > Gate 2020 > function
Consider the following C functions.
The value returned by pp(3,4) is ________ .
int tob (int b, int* arr) {
int i;
for (i = 0; b>0; i++) {
if (b%2)
arr [i] = 1;
else
arr[i] = 0;
b = b/2;
}
return (i);
}
int pp(int a, int b) {
int arr[20];
int i, tot = 1, ex, len;
ex = a;
len = tob(b, arr);
for (i=0; i
if (arr[i] ==1)
tot = tot * ex;
ex= ex*ex;
}
return (tot) ;
}
int i;
for (i = 0; b>0; i++) {
if (b%2)
arr [i] = 1;
else
arr[i] = 0;
b = b/2;
}
return (i);
}
int pp(int a, int b) {
int arr[20];
int i, tot = 1, ex, len;
ex = a;
len = tob(b, arr);
for (i=0; i
tot = tot * ex;
ex= ex*ex;
}
return (tot) ;
}
The value returned by pp(3,4) is ________ .
Explanation
Correct : 81
Similar Questions
What is the worst-case time complexity of insertion in an AVL tree?
Which operations on a binary search tree have O(h) complexity?
Compare search complexities of sorted array vs balanced BST.