Wednesday, August 21, 2013

Program to illustrate the working of new and delete operators

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,i;
cout<<"Enter the number of students in the class : ";
cin>>n;
int *p=new int[n];
int *q=new int[n];
cout<<"Input the class numbers : ";
for(i=0;i<n;i++)
cin>>*(p+i);
cout<<"Input the marks : ";
for(i=0;i<n;i++)
cin>>*(q+1);
cout<<"The list of students with marks : ";
for(i=0;i<n;i++)
cout<<"\n"<<*(p+i)<<"\t"<<*(q+i);
delete [] p;
delete [] q;
getch();
}

For more details about pointers click here

No comments:

Post a Comment