# by R4R Team

Here we want to delete the maxiumum element in the given array:

Example-
Array is [2,9,3,5,1]
After deletion of max
Array is [2,3,5,1]

program-

#include< stdio.h>
int main()
{
int a[20],n,i,location,max;
printf("Enter number of elements in arary\n");
scanf("%d",&n);
printf("Enter %d number in array\n",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 maximum number index value
max=a[0];
for(i=0;i< n;i++){
if(a[i]>max)
{
max=a[i];
location=i;
}
}
for(i=location;i< n-1;i++)
a[i]=a[i+1];
printf("Array after deletion of maximum number is ");
for(i=0;i< n-1;i++)
printf("%d ",a[i]);
}

output-

Ener number of elemenmts in array
6
Enter 6 number in array
1 6 3 4 1 2
Array is
1 6 3 4 1 2
After deletion of maximum number is
1 3 4 1 2

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