HOME

Tuesday, January 31, 2017

DELETION OF ARRAY ELEMENT IN C

#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],i,p,n;
printf("Enter size of array\n");
scanf("%d",&n);
printf("Enter the value in array\n");
for(i=0;i<n;i++)
{
    scanf("%d",&a[i]);
}
printf("The value you entered in array are:\n");
for(i=0;i<n;i++)
{
    printf("%d\n",a[i]);
}
printf("Enter the position of element to delete\n");
scanf("%d",&p);
for(i=p;i<n;i++)
{
a[i-1]=a[i];
}
printf("Array after deletion is:\n");
for(i=0;i<n-1;i++)
{
    printf("%d\n",a[i]);
}
getch();
}

No comments:

Post a Comment