1.

Assume that in a city, two football matches are going to be held. The coordinators of the match have decided to sell the tickets in two different styles. For the first match, the tickets will be sold one month in advance, but for the second one, tickets will be available from the stadium on the very same day of the match.1. Correlate this situation with the memory allocation techniques in C++. 2. Compare the merits and demerits of the two in relation with the given context.

Answer»

1. Static and dynamic memory allocation. 

2. Every data and instruction data is being executed must be allocated some area in the main memory. The main memory can be allocated in two methods. 

  • Static memory allocation 
  • Dynamic memory allocation

When the amount of memory to be allocated is known in advance and memory is allocated during compilation itself, it is referred to as static memory allocation. When the amount of memory to be allocated is not known in advance and it is required to allocate memory as and when required during run time, it is known as dynamic memory allocation.



Discussion

No Comment Found