Multiple choice technology mainframe

"QSTACK" "NEWSTACK" "NEWSTACK" "QSTACK" What will the last "QSTACK" will return.

  1. Returns 0

  2. Returns 1

  3. Returns 2

  4. Returns 3

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Tracing the stack operations: QSTACK (returns 0 for initial stack), NEWSTACK (creates new stack level 1), NEWSTACK (creates another stack level 2), QSTACK (returns 3 - the current stack depth after two NEWSTACKs added to the initial stack). Each NEWSTACK increments the stack depth by 1.