Tag: Delete Element in Array
Delete Element in Array
by Binod on Dec.14, 2010, under C & C++, DSA in C, Tutorial
//WAP to DELETE element in an array using C and algorithm
#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
int a[8]={1,2,3,4,5,6,7, },pos=0,val;
printf(“befor DELETE: “);
for(int i=0;i<8;i++){
printf(“%d”,a[i]);
}
printf(“\n Enter the position of the element to DELETE in array: “);
scanf(“%d”,&pos);
printf(“after DELETE: “);
pos=pos-1;
for(i=pos;i<8;i++){
a[i]=a[i+1] ;
}
for(i=0;i<8;i++){
printf(“%d”,a[i]);
}
getch();
return 0;
}