/*********************************************************
Program to find maximum and minimum element in the array
*********************************************************/
#include<stdio.h> // include stdio.h library
#define MAX 5
int main(void)
{
int arr[MAX] = {50, -100, 20, 245, 0},
min, max;
min = max = arr[0]; // assign the first element to max and min
for(int i = 0; i < MAX; i++)
{
if(arr[i] < min)
{
min = arr[i];
}
if(arr[i] > max)
{
max = arr[i];
}
}
printf("Min = %d\n", min);
printf("Max = %d", max);
return 0; // return 0 to operating system
}