GATE CS 2026 (Forenoon) — Question 61

Programming in CFunctions, Parameter Passing, Scope Rules, RecursionNAT2 marksHard

Consider the recursive functions represented by the following code segment:
c
1int bar(int n){
2    if (n == 1) return 0;
3    else return 1 + bar(n/2);
4}
5int foo(int n){
6    if (n == 1) return 1;
7    else return 1 + foo(bar(n));
8}
9
The smallest positive integer n for which foo(n) returns 5 is ________. (answer in integer) Note: Ignore syntax errors (if any) in the function.
Practise the full 2026-FN paper
Challenge a friend: WhatsApp Telegram
From RENYXERAWhat rank do your marks get?GATE score, likely All-India Rank and qualifying marks for your category.
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