Discussion
Local variables are stored in an area called ___________
Answer: D
Correct answer: Stack
Local variables have automatic storage duration: created on entry to their block and destroyed on exit. A stack matches that pattern exactly, since the most recently created is always the first to be destroyed.
Allocation therefore costs only an adjustment of the stack pointer, which is why automatic variables are far cheaper than heap blocks. The same mechanism is why returning the address of a local is a fault - the storage is reclaimed as the function returns.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development