memory allocation in programs supports three kinds of memory allocation through the variables in programsstatic allocation when we declare static or global variablestatic allocation is done for the variable each static or global variable is allocated fixed size of memory space the number of bytes reserved for the variable cannot change during execution of the program automatic allocation when we declare an automatic variablesuch as function argument or local variableautomatic memory allocation is done the space for an automatic variable is allocated when the compound statement containing the declaration is enteredand is freed when it exits from compound statement dynamic allocation third important kind of memory allocation is known as dynamic allocation in the following sections we will read about dynamic memory allocation using pointers memory usage before jumping into dynamic memory allocationlet us first understand how memory is used conceptuallymemory is divided into two parts--program memory and data memory (fig memory program memory main(figure other function data memory global stack heap memory usage the program memory consists of memory used for the main(and other called functions in the programwhereas data memory consists of memory needed for permanent definitions such as global datalocal dataconstantsand dynamic memory data the way in which handles the memory requirements is function of the operating system and the compiler when program is being executedits main(and all other functions are always kept in the memory howeverthe local variables of the function are available in the memory only when they are active when we studied recursive functionswe have seen that the system stack is used to store single copy of the function and multiple copies of the local variables