Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
42 views3 pages

Dynamic Memory Allocation 1

This C++ program demonstrates dynamic memory allocation and deallocation. The user inputs the size of an integer array. Memory is dynamically allocated for the array using new and the elements are input. The elements are then outputted and the memory for the array is released using delete.

Uploaded by

dhilipkumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views3 pages

Dynamic Memory Allocation 1

This C++ program demonstrates dynamic memory allocation and deallocation. The user inputs the size of an integer array. Memory is dynamically allocated for the array using new and the elements are input. The elements are then outputted and the memory for the array is released using delete.

Uploaded by

dhilipkumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

DYNAMIC MEMORY ALLOCATION PROGRAM CODINGS:#include<iostream.h> #include<conio.

h> void main() { int i,n; int *p; clrscr(); cout<<"\n ENTER THE SIZE OF ARRAY:"; cin>>n; p=new int[n]; for(i=0;i<n;i++) { cout<<"\n ALLOCATED MEMORY"<<i+1; cin>>p[i]; } for(i=0;i<n;i++) { cout<<p[i]; cout<<"\t RELEASED MEMORY\t"<<i+1<<"\n"; } delete[]p; }

OUTPUT:Enetr the size of array 3 ALLOCATED MEMORY1 ALLOCATED MEMORY2 ALLOCATED MEMORY3 RELEASED MEMORY1 RELEASED MEMORY2 RELEASED MEMORY3

RESULT:-

You might also like