- Write a program to perform deletion operation on Array.
- #include<stdio.h>
#include<conio.h>
void delete (int[], int, int);
main()
{
int a[100], size, i, position;
printf ("Enter the size of an array = ");
scanf ("%d",&size);
printf ("Enter %d elements :-\n",size);
for(i=0;i<size;i++)
{
scanf ("%d",&a[i]);
}
printf ("Enter the positon which you want to delete = ");
scanf ("%d",&position);
delete (a, size, position-1);
}
void delete (int a[], int size, int position)
{
int i;
for (i=position;i<=size;i++)
{
a[i]=a[i-1];
if(i==position)
{
break;
}
}
a[i]=0;
for (i=0;i<size;i++)
{
printf ("%d = [%d]\n", i, a[i]);
}
}
0 Comments
Thank You ! For your love