# Delete minimum in Array Data structure by R4R Team

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]);
}

output-

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

-In this program, we take an input in array, and try to find minimum element first.
-When we have a min element then we proceed to delete that number.
-Here we store the index value of the min element in variable 'location'.
-Then we just traverse and delete that index value.