GATE CS 2015, set 2 · Question 52 · Programming and Data Structures · Numerical answer (NAT) · 2 marks · no negative marks

Consider the C program below.
#include <stdio.h> int *A, stkTop; int stkFunc(int opcode, int val) static int size=0, stkTop=0; switch (opcode) case -1: size = val; break; case 0: 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 ( 0, 5); stkFunc ( 0, 10); printf ("%d ", stkFunc(1, 0) + stkFunc(1, 0));
The value printed by the above program is ______.

Answer

Answer 15

Answer from the official GATE CS 2015 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes