Skip to content

Beta · Data may be lost.Your data may be reset or lost.

GateBrew
← GATE CSE 2025 Set 1
Questions

Q51

NAT2 marks
#include <stdio.h>
int foo(int S[],int size) {
    if(size == 0) return 0;
    if(size == 1) return 1;
    if(S[0] != S[1]) return 1+foo(S+1,size-1);
    return foo(S+1,size-1);
}
int main() {
    int A[]={0,1,2,2,2,0,0,1,1};
    printf("%d",foo(A,9));
    return 0;
}

The value printed by the given CC program is ___________. (Answer in integer)

Sign in to save attempts.

Solutions and discussion are hidden while you attempt this question. They open once you check or show the answer.