Skip to content

Commit 66b84df

Browse files
Add files via upload
1 parent 219382c commit 66b84df

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

27_dynamicmemoryallocation.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main(){
5+
// Dynamic memory allocation is a technique of demaning memory from Heap at Runtime. Generally, the memory which we demand was made fixed at compile time and is allocated in stack memory. So when we demand memory from heap, the allocated memory is provided and base address is returned which can be accessed using a pointer
6+
//Whenever we need to get memory dynamically allocated, we need to use " new " keyword.
7+
8+
int *ptr = new int;//how much memory is to be allocated decided at runtime
9+
cout<<"Enter the integer value: ";
10+
cin>>*ptr;
11+
12+
cout<<"Value is: "<<*ptr<<endl;
13+
14+
15+
16+
return 0;
17+
}

27_dynamicmemoryallocation.exe

44.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)