> For the complete documentation index, see [llms.txt](https://abhyas-kanaujia.gitbook.io/lb-dsa-notes-and-homework-abhyas/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://abhyas-kanaujia.gitbook.io/lb-dsa-notes-and-homework-abhyas/18-static-and-dynamic-allocation/classwork/01-dynamic-allocaiton-of-variable.md).

# 01 Dynamic Allocaiton of variable

```cpp
#include <bits/stdc++.h>
using namespace std;

int main()  {
    // dynamic allocaiton of variable
    int *ptr = new int;
    
    // assign value to variable
    *ptr = 5;
    
    // use variable
    cout << *ptr;
    
    // deallocate variable
    delete ptr;
    
    return 0;
}
```
