#include<stdio.h>
#include<conio.h>
main()
{
int a[10];
int n,loc;
printf("enter the size of an array:-");
scanf("%d",&n);
printf("\nenter the elements:-");
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\nenter the postion of the element you want to delete:-");
scanf("%d",&loc);
if(loc >= n+1 )
printf("\nDeletion not possible.\n");
else
{
for(int i=loc-1;i<n-1;i++)
{
a[i]=a[i+1];
}
}
printf("\narray after deleting element is:-");
for(int i=0;i<n-1;i++)
{
printf("%d\n",a[i]);
}
getch();
}Thursday, September 22, 2016
C program for deletion in arrays
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment