Link List Program Data Structure :: Array

Link List Program Data Structure :: Array :: Delete

#include<iostream.h>
#define L 0
#define U 10
void main()
{
int a[U],i,del,temp,found=0;
temp=U;
for(i=L;i<U;i++)
{
cout<<“Enter a[“<<i<<“]”;
cin>>a[i];
}
cout<<“Enter the element you want to delete:”;
cin>>del;
for(i=L;i<U;i++)
{
if(a[i]==del)
{
for(;i<U;i++)
a[i]=a[i+1];
found=1;
break;
}
}
if(found==1)
{
a[U]=NULL;
temp=temp-1;
for(i=L;i<temp;i++)
cout<<a[i]<<endl;
}
else
cout<<“Deletion won’t be possible as element is not found”;
}

Share

About the Author

Akash Padhiyar

Visit Website

There are no comments yet, add one below.

Leave a Comment

Your email address will not be published. Required fields are marked *

*

Time limit is exhausted. Please reload CAPTCHA.