//Deletion from array
#include <stdio.h>
#include <conio.h>
void main()
{
int a[100], pos, i, n;
clrscr();
printf("How many elements\n");
scanf("%d", &n);
//Entry of desired elements
printf("Enter %d elements\n", n);
for ( i = 0 ; i < n ; i++ )
{
scanf("%d", &a[i]);
}
printf("Location to delete?\n");
scanf("%d", &pos);
if ( pos >= n+1 )
{
printf("Not Possible to Delete\n");
}
else
{
for ( i = pos - 1 ; i < n - 1 ; i++ )
a[i] = a[i+1];
printf("Now the Array is\n");
for( i = 0 ; i < n - 1 ; i++ )
printf("%d\n", a[i]);
}
getch();
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.