/*
new keyword is used to allocate dynamic memory for the variable.
Syntax
<data_type> pointer_variable
pointer_variable=new <data_type>[size]
deallocation of memory is done by delete keyword.
*/
#include<iostream.h>
#include<conio.h>
void main()
{
int *n,i;
n=new int[5];
cout<<"Enter element :\n";
for(i=0;i<5;i++)
cin>>n[i];
cout<<"\nElements are :\n";
for(i=0;i<5;i++)
cout<<n[i]<<" ";
delete(n);
getch();
}
Output
new keyword is used to allocate dynamic memory for the variable.
Syntax
<data_type> pointer_variable
pointer_variable=new <data_type>[size]
deallocation of memory is done by delete keyword.
*/
#include<iostream.h>
#include<conio.h>
void main()
{
int *n,i;
n=new int[5];
cout<<"Enter element :\n";
for(i=0;i<5;i++)
cin>>n[i];
cout<<"\nElements are :\n";
for(i=0;i<5;i++)
cout<<n[i]<<" ";
delete(n);
getch();
}
Output
No comments:
Post a Comment