Page

Saturday, 22 September 2018

program for deletion a program in c

#include<stdio.h>
#include<conio.h>
void main()
{
int a[100], pos ,i ,n ;
clrscr();
printf("enter no. of element in array\n");
scanf("%d", &n);
printf("\n enter %d element ",n);
for (i=0;i<n;i++)
scanf("%d",&a[i]) ;
printf("\n enter location where you want to delete element ");
scanf("%d",&pos) ;
if (pos >= n+1)
printf("\n deletion not possible");
else
{
for (i=pos-1;i<n;i++)
a[i]=a[i+1];
printf ("\n resultant array ");
for (i=0;i<n-1;i++)
printf("%d\n",a[i]) ;
}
getch ();
}




No comments:

Post a Comment