Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Static Memory Allocation

Static Memory Allocation

 

When the amount of memory to be allocated is known beforehand, i.e., it is known as Static Memory Allocation at the time of compilation. Once the memory is allocated statically, it cannot be deallocated during the program run. So it leads to wastage of storage space. We generally pass constants while declaring arrays.

 

Syntax:

int A[100];

 

Example:

#include <iostream>
using namespace std;
int main() {
    int a[100];
    const int size = 5;
    int b[size];
    return 0;
}

 

👉 Get Access to Structured Video Content from Top Faculty and 1-on-1 Doubt Support. Start Your Free Trial Today!