CODINGCLASSES|LEARNTOPROGRAM
DATA STRUCTURE
WAP TO DELETE AN ELEMENT FROM THE ARRAY
#include<iostream.h>
#include<conio.h>
void main()
{
int A[100],n,i,loc;
cout<<"Enter the size of an array= ";
cin>>n;
cout<<"Enter the element of an array ";
for(i=0; i<=n; i++)
{
cin>>A[i];
}
cout<<"Enter the location of element to delete ";
cin>>loc;
if(loc>n)
{
cout<<"The value is out of range ";
}
else
--loc;
for(i=loc; i<=n; i++)
{
A[i]=A[i+1];
}
cout<<"New Array ";
for(i=0; i<n-1; i++)
{
cout<<A[i];
}
getch();
}
OUTPUT:-
Enter the size of an array =5
The element of an array
2
DATA STRUCTURE
WAP TO DELETE AN ELEMENT FROM THE ARRAY
#include<iostream.h>
#include<conio.h>
void main()
{
int A[100],n,i,loc;
cout<<"Enter the size of an array= ";
cin>>n;
cout<<"Enter the element of an array ";
for(i=0; i<=n; i++)
{
cin>>A[i];
}
cout<<"Enter the location of element to delete ";
cin>>loc;
if(loc>n)
{
cout<<"The value is out of range ";
}
else
--loc;
for(i=loc; i<=n; i++)
{
A[i]=A[i+1];
}
cout<<"New Array ";
for(i=0; i<n-1; i++)
{
cout<<A[i];
}
getch();
}
OUTPUT:-
Enter the size of an array =5
The element of an array
2
3
4
7
8
9
Enter the location of element to delete=4
New array
2
3
7
8
9
HII friends !!this coding is already checked in Turbo c++ Ide
there is no any run and compiled time error ...
keep visiting !!for latest update If you have any request about
any programming and question plz comment below or email...
No comments:
Post a Comment