GATE Assistant

Past questions › Computer Science and Information Technology › GATE 2021 set1

GATE 2021 set1 · CS · NAT · 2 marks · Programming and Data Structures › C Programming Fundamentals

GATE 2021 set1 Computer Science and Information Technology question: Consider the following ANSI C function: code Let Z be an array of 10 elements with…

Consider the following ANSI C function:

int SimpleFunction(int Y[], int n, int x)
{
    int total = Y[0], loopIndex;
    for (loopIndex = 1; loopIndex <= n - 1; loopIndex++)
        total = x * total + Y[loopIndex];
    return total;
}

Let Z be an array of 10 elements with Z[]=1, for all such that . The value returned by SimpleFunction(Z, 10, 2) is ________.

Show answer

Official answer: 1023

Practise this question with exam-style marking

Discussion

No discussion yet.

Join the discussion