Skip to content

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

GateBrew
← GATE CSE 2014 Set 1
Questions

Q41

MCQ2 marks, −0.67AlgorithmsMedium

Consider the following C function in which size is the number of elements in the array E:

int MyX(int *E, unsigned int size)
{
    int Y = 0;
    int Z;
    int i, j, k;
    for(i = 0; i< size; i++)
        Y = Y + E[i];
    for(i=0; i < size; i++)
        for(j = i; j < size; j++)
        {
            Z = 0;
            for(k = i; k <= j; k++)
                Z = Z + E[k];
            if(Z > Y)
                Y = Z;
        }
    return Y;
}

The value returned by the function MyX is the

Sign in to save attempts.

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