Dynamic Memory Allocation_advantage

is there any advantage to allocate memory at run time than at compile time?

hey @rajukumarbhui, it helps to avoid wastage of memory. Let say question ask you store elements in array. Max elements that can be store is 100 but sometimes only 80 are used then that 20 gets waste if you do static memory allocation. This can be overcome in Dynamic memory allocation.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.