GATE CS 2018 (Forenoon) — Question 31

Programming in CFunctions, Parameter Passing, Scope Rules, RecursionNAT1 markMedium

Consider the following C program:
c
1#include <stdio.h>
2
3int counter = 0;
4
5int calc (int a, int b) {
6 int c;
7 counter++;
8 if (b==3) return (a*a*a);
9 else {
10 c = calc(a, b/3);
11 return (c*c*c);
12 }
13}
14
15int main (){
16 calc(4, 81);
17 printf ("%d", counter);
18}
19
The output of this program is _____.
Practise the full 2018-FN paper
Challenge a friend: WhatsApp Telegram
From RENYXERAPractise this subject in the exam simulatorTimed, GATE-style tests with analytics that find your weak topics.
Practise more on Functions, Parameter Passing, Scope Rules, RecursionTimed, in the real exam interface · free to start

A GATE question every morning

One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.

Join
Stuck? Ask in the student group