GATEverse Practice, past papers & mock tests
GATE 2026 · CS2 - Afternoon
Programming & Data StructuresProgramminghardNAT2 marks
Consider the following ANSI-C function.
c
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.
Save your progress

Related Programming & Data Structures PYQs