## Deletion Operation in Array

This operation is used to delete an element from specific position from one dimensional array.
In order to delete an element from one dimensional array first we have to delete element from specified position and then shift remaining elements upwards to take vacant space of the deleted element.

## Algorithm For Deletion Operation in Array

Step 1: POS = POS - 1
TEMP = POS
Step 2: Return A [POS]
Step 3: Repeat Step4 while TEMP ≤ N-1
Step 4: A [TEMP] = A [TEMP + 1]
TEMP = TEMP + 1
Step 5: N = N-1

## Program For Deletion Operation in Array

#include<stdio.h>
#include<conio.h>
#define N 5
void main()
{
int a[N]={10,20,30,40,50};
int POS,x;
void traverse(int *a,int n);
void del(int *a,int POS);
clrscr();
printf("Before Deletion\n");
traverse(a,N);
printf("Enter Position:");
scanf("%d",&POS);
del(a,POS);
printf("After Deletion\n");
traverse(a,N-1);
getch();
}
void del(int *a,int POS)
{
POS=POS-1;
int TEMP=POS;
printf("Deleted Element is %d",a[POS]);
while(TEMP<=N-1)
{
a[TEMP]=a[TEMP+1];
TEMP=TEMP+1;
}
}
void traverse(int *a,int n)
{
int START=0;
while(START<n)
{
printf("%d\n",a[START]);
START=START+1;
}
}