GATE CS 2018 · Question 31 · Programming and Data Structures · Numerical answer (NAT) · 1 mark · no negative marks

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 ______.

Answer

Answer 4

Answer from the official GATE CS 2018 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes