GATE DA 2025 · Question 64 · Programming, Data Structures and Algorithms · Numerical answer (NAT) · 2 marks · no negative marks
Consider the following pseudocode.
Create empty stack S Set x=0, flag=0, sum=0 Push x onto S while (S is not empty){ if (flag equals 0){ Set x = x+1 Push x onto S} if (x equals 8): Set flag=1 if (flag equals 1){ x = Pop(S) if (x is odd): Pop(S) Set sum = sum + x} } Output sum
The value of sum output by a program executing the above pseudocode is ______ (Answer in integer)
Answer
Answer 24
Answer from the official GATE DA 2025 answer key.
The step-by-step solution, where available, is part of GATE DA Pro. See what Pro includes