GATE CS 2026 (Afternoon) — Question 61

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

Consider the following ANSI-C function.
c
1int func(int start, int end){
2    int length = end + 1 - start;
3    if((length<1) || (start < 0) || (end<0)){ return(0); }
4    if(length%3 == 0){
5        return(func(start+1, end));
6    } else if(length%3 == 1){
7        return(1 + func(start, end -1));
8    } else {
9        return(func(start + 2, end));
10    }
11}
12
The maximum possible value that can be returned from this function is ________. (answer in integer) Note: Ignore syntax errors (if any) in the function.
Practise the full 2026-AN 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