MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

COMPILER DESIGN

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Each time a procedure is called, space for its local variable is pushed onto ____
A
buffer
B
registers
C
stack
D
memory
Explanation: 

Detailed explanation-1: -Each time a procedure is called, space for its local variables is pushed onto a stack, and when the procedure terminates, that space is popped off the stack. It works on the basis of last-in-first-out (LIFO) and this allocation supports the recursion process.

Detailed explanation-2: -When a new local variables is declared, more stack memory is allocated for that function to store the variable. Such allocations make the stack grow downwards. After the function returns, the stack memory of this function is deallocated, which means all local variables become invalid.

Detailed explanation-3: -In a high-level language a local variable is implemented as a location on the run-time stack. Each time a subroutine is activated, new locations for variables are pushed onto the stack. The section of the stack for each activation is called a stack frame or an activation record.

Detailed explanation-4: -Activation record: When a function calls another function, an entry is pushed to the stack. This entry is called as Activation Record. Activation record contains parameters, local variables, and return address that the called function needs to return to the calling function.

Detailed explanation-5: -New activation records are PUSHed onto the stack during procedure calls and the POPed from the stack when the procedure call returns.

There is 1 question to complete.