Gate CS-2015-2 Question Paper With Solutions

Q. 65 Consider the C program below.

#include <stdio.h>
int *A, stkTop;
int stkFunc (int opcode, int val)
{
    static int size=, stkTop=;
    switch (opcode) {
        case -1: size = val; break;
        case : if (stkTop < size ) A[stkTop++]=val; break;
        default: if (stkTop) return A[--stkTop];
    }
    return -1;
}
int main()
{
    int B[20]; A=B; stkTop = -1;
    stkFunc (-1, 10);
    stkFunc (, 5);
    stkFunc (, 10);
    printf ("%d\n", stkFunc(1, )+ stkFunc(1, ));
}

The value printed by the above program is ___________

(A) 9

(B) 10

(C) 15

(D) 17

Answer: (C)

Explanation:

Gate CS-2015-2 Question Paper With Solutions

 

Learn More:   Gate EC-2007 Question Paper With Solutions

LEAVE A REPLY

Please enter your comment!
Please enter your name here