Gate CS-2018 Question Paper With Solutions

Q. 14 Consider the following C program:

#include <stdio.h>    int counter = 0;    int calc(int a, int b) {    int c;      counter++;    if (b == 3)      return (a * a * a);    else {      c = calc(a, b / 3);      return (c * c * c);    }  }    int main() {    calc(4, 81);    printf("%d", counter);  } 

The output of this program is ________ .

Note – This was Numerical Type question.

(A) 5

 

(B) 4

(C) 3

(D) None of these

Answer: (B)

Explanation:

Gate CS-2018 Question Paper With Solutions

Learn More:   Gate EE-2020 Question Paper With Solutions

LEAVE A REPLY

Please enter your comment!
Please enter your name here