GATE | GATE CS 2018 | Question 14

Consider the following C program:

filter_none

edit
close

play_arrow

link
brightness_4
code

#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);
}

chevron_right


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: 1

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

1


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