Here we want to delete the minimum element in the given array:
Example-
Array is [2,0,3,5,1,8]
After deletion of max
Array is [2,3,5,1,8]
program-
#include< stdio.h>
int main()
{
int a[20],n,i,location,min;
printf("Enter number of elements in arary\n");
scanf("%d",&n);
printf("Enter %d number in array",n);
for(i=0;i< n;i++)
scanf("%d",&a[i]);
printf("Array is\n");
for(i=0;i< n;i++)
printf("%d ",a[i]);
//find minimum number index value
min=a[0];
for(i=0;i< n;i++){
if(a[i]< min)
{
min=a[i];
location=i;
}
}
for(i=location;i< n-1;i++)
a[i]=a[i+1];
printf("Array after deletion of minimum number is \n");
for(i=0;i< n-1;i++)
printf("%d ",a[i]);
}
Enter number of elements in array
6
Enter 6 number in array
0 1 2 3 4 5
Array is
0 1 2 3 4 5
Array after deletion of minimum number is
1 2 3 4 5