#include<iostream.h>
#include<conio.h>
int *arr;
void main()
{
int size,i,pos;
clrscr();
cout<<"How Many Numbers You Want to Add :";
cin>>size;
arr=new int[size];
for(i=0;i<size;i++)
{
cout<<"Enter "<<i+1<<" Number :";
cin>>arr[i];
}
cout<<"Before Deletation :"<<endl;
for(i=0;i<size;i++)
{
cout<<arr[i]<<endl;
}
cout<<"From Which Position You Want to Delete Number :";
cin>>pos;
if(pos>=1 && pos<=size)
{
for(i=pos-1;i<size;i++)
{
arr[i]=arr[i+1];
}
size--;
cout<<"After Delete Number From Array :"<<endl;
for(i=0;i<size;i++)
{
cout<<arr[i]<<endl;
}
}
else
cout<<"Select Position From 1 to "<<size;
delete []arr;
getch();
}
#include<conio.h>
int *arr;
void main()
{
int size,i,pos;
clrscr();
cout<<"How Many Numbers You Want to Add :";
cin>>size;
arr=new int[size];
for(i=0;i<size;i++)
{
cout<<"Enter "<<i+1<<" Number :";
cin>>arr[i];
}
cout<<"Before Deletation :"<<endl;
for(i=0;i<size;i++)
{
cout<<arr[i]<<endl;
}
cout<<"From Which Position You Want to Delete Number :";
cin>>pos;
if(pos>=1 && pos<=size)
{
for(i=pos-1;i<size;i++)
{
arr[i]=arr[i+1];
}
size--;
cout<<"After Delete Number From Array :"<<endl;
for(i=0;i<size;i++)
{
cout<<arr[i]<<endl;
}
}
else
cout<<"Select Position From 1 to "<<size;
delete []arr;
getch();
}
No comments:
Post a Comment