Wednesday, 2 July 2014

Deletion in array

#include<conio.h>
#include<stdio.h>
main()
{
int arr[10],n,i,pos;
printf("enter the size of array");
scanf("%d",&n);
arr[n];
printf("enter the element of array");
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);

}
printf("enter the position you want to delete the element");

scanf("%d",&pos);
for(i=pos-1;i<n;i++)
arr[i]=arr[i+1];

n--;

printf("after deletion the array ----\n");
for(i=0;i<n;i++)
printf("\n %d",arr[i]);

getch();
return 0;

}


No comments:

Post a Comment