# GATE | GATE CS 2020 | Question 58

Consider the following C functions.

 `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

The value returned by pp(3,4) is ________ .

Note – This question was Numerical Type.
(A) 81
(B) 64
(C) 100
(D) 49

Explanation: Given functions compute power of an elements, so it will print 3^4 = 81.

 `#include   ` ` `  `int` `tob (``int` `b, ``int``* arr); ` `int` `pp(``int` `a, ``int` `b); ` ` `  `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

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.