#include<iostream.h>
#include<conio.h>
int del(int a[],int n,int data)
{
int i,j;
for(i=0;i<n;i++)
{
if(a[i]==data)
{
for(j=i+1;j<n;j++)
a[j-1]=a[j];
return 1;
}
}
return -1;
}
void main()
{
clrscr();
int a[50],i,n,element,f;
cout<<"Enter the number of elements ";
cin>>n;
cout<<"Enter the elements";
for(i=0;i<n;i++)
{
cin>>a[i];
}
cout<<"Enter the elementto be deleted";
cin>>element;
f=del(a,n,element);
if(f==1)
{
cout<<"After Deletion";
for(i=0;i<n-1;i++)
{
cout<<a[i]<<",";
}
}
else
cout<<"Element Not Found";
getch();
}
#include<conio.h>
int del(int a[],int n,int data)
{
int i,j;
for(i=0;i<n;i++)
{
if(a[i]==data)
{
for(j=i+1;j<n;j++)
a[j-1]=a[j];
return 1;
}
}
return -1;
}
void main()
{
clrscr();
int a[50],i,n,element,f;
cout<<"Enter the number of elements ";
cin>>n;
cout<<"Enter the elements";
for(i=0;i<n;i++)
{
cin>>a[i];
}
cout<<"Enter the elementto be deleted";
cin>>element;
f=del(a,n,element);
if(f==1)
{
cout<<"After Deletion";
for(i=0;i<n-1;i++)
{
cout<<a[i]<<",";
}
}
else
cout<<"Element Not Found";
getch();
}