GATE CS 2021 (Forenoon) — Question 58

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

Consider the following ANSI C function:
c
1int SimpleFunction (int Y[ ], int n, int x)
2{
3    int total = Y[0], loopIndex;
4    for (loopIndex = 1; loopIndex <= n - 1; loopIndex++)
5        total = x * total + Y[loopIndex];
6    return total;
7}
8
Let Z be an array of 10 elements with \(Z[i] = 1\), for all \(i\) such that \(0 \leq i \leq 9\). The value returned by SimpleFunction (Z, 10, 2) is _________.
Practise the full 2021-FN paper
Challenge a friend: WhatsApp Telegram
From RENYXERAThis week's 10-question challengeSame 10 past-GATE questions for everyone this week — see where you stand.
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