GATE CS 2025 (Forenoon) — Question 61

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

c
1#include <stdio.h>
2int foo(int S[ ], int size) {
3    if(size == 0) return 0;
4    if(size == 1) return 1;
5    if(S[0] != S[1]) return 1 + foo(S + 1, size - 1);
6    return foo(S + 1, size - 1);
7}
8int main( ) {
9    int A[ ] = {0, 1, 2, 2, 2, 0, 0, 1, 1};
10    printf("%d", foo(A, 9));
11    return 0;
12}
13
The value printed by the given C program is ________. (Answer in integer)
Practise the full 2025-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