GATE CS 2026, set 2 · Question 61 · Programming and Data Structures · Numerical answer (NAT) · 2 marks · no negative marks
Consider the following ANSI-C function.
int func(int start, int end){ int length=end+1-start; if((length<1)||(start<0)||(end<0)){ return(0); } if(length%3==0){ return(func(start+1, end)); } else if(length%3==1){ return(1+func(start, end-1)); } else { return(func(start+2, end)); } }
The maximum possible value that can be returned from this function is ______. ( answer in integer )
Note : Ignore syntax errors (if any) in the function.
Answer
Answer 1
Answer from the official GATE CS 2026 answer key.
The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes