asked 192k views
3 votes
When does the memory space allocated to local variables and parameters get deallocated? When the application ends, the memory space allocated to local variables and parameters of both the called function and calling program is deallocated. O When the calling program ends, the memory space allocated to local variables and parameters of the called function is deallocated. When the called function ends, the memory space allocated to local variables and parameters of the calling program is deallocated. When the called function ends, the memory space allocated to local variables and parameters of the called function is deallocated. O

1 Answer

4 votes

Answer:

last option: When the called function ends, the memory space allocated to local variables and parameters of the called function is deallocated.

Step-by-step explanation:

A function, when it is called, uses the stack to allocate local variables. When it exits, those variables are no longer needed (since they are local), so the stack pointer is reset to the position it had before calling the function.

answered
User Mark Thien
by
7.4k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.