C program to find maximum and minimum element in an array is a program to find the minimum and maximum value in an array.

Array: It is used to store the collection of similar types of data.
We find the minimum and maximum value in the given array.

Page Contents

## Algorithm to find minimum and maximum in array

1. Declare variables. min, max,a[size]
2. Take a numbers input from user in array. a[size]
min = max = a[0]
3. Traverse array start to end
for i = 1 to end
If a[i] > max
max = a[i]
If [i] < min
min = a[i]
4. Print the min and max value

## C program to find maximum and minimum element in array

```#include<stdio.h>
main()
{
int i,size,max=0,min=0;
printf("Enter size to find largest and smallest of given numbers\n");
scanf("%d",&size);
int a[size];
printf("Enter numbers in array\n");
for(i=0;i<size;i++)
{
scanf("%d",&a[i]);
}
min=a[0];
max=a[0];
for(i=1;i<size;i++)
{
if(a[i]>max)
{
max=a[i];
}
if(a[i]<min)
{
min=a[i];
}
}
printf("The largest number is %d\n",max);
printf("The smallest number is %d\n",min);
}```

Output :