Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
166 views
in Structures and Pointers by (31.3k points)
closed by

When a C++ program is executed, the primary memory allocated for it is organized in a particular manner to deal with runtime memory allocation, function calls, variables, etc. Show a diagrammatic representation of it with brief explanation.

1 Answer

+1 vote
by (30.9k points)
selected by
 
Best answer

After compilation of C++ creates four distinct regions of memory used for distinct functions:

STACK 3
HEAP 4
GLOBAL Program
Variables Code
2 1

The first area 

(1) is used for storing the compiled code of the program. The second area 

(2) is used for storing global variables of the program. It remains in memory till the program ends. The third region 

(3) known as the stack is used for holding the return addresses of function calls, arguments passed to the function, etc. The last region heap is used for dynamic allocation.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

...