C Program to Find Maximum and Minimum Number in An Array with Algorithm

Here is the C program and step by step algorithm to find maximum and minimum number in array.
Algorithm & C Program to Find Maximum and Minimum Number in An Array
Aim:
Write a C program to find the maximum and minimum numbers in an array.
Algorithm
Step 1: Begin.
Step 2: Declare an integer array variable, array1 with size 15.
Step 3: Read the size of the array and assigned to a variable, size.
Step 4: Read the array elements and assigned to the variable, array1.
Step 5: Initilize max=min=array[0].
Step 6: Initilize i=0 and repeat steps 7 to 11 till array1[0]>=size.
Step 7: Check whether min < array1[i], if yes do step 8 else step 9.
Step 8: Assign min= array1[i].
Step 9: Check whether max > array1[i], if yes do step 10 else step 11.
Step 10: Assign max=array1[i].
Step 11: Increment i by 1.
Step 12: Print min and max.
Step 13: End.
C Program
#include
#include
void main()
{
int array1[15], i, max, min, size;
clrscr();
printf(" Enter the size of array :");
scanf("%d",&size);
printf(" Enter the array elements :");
for(i=0; i<size; i++)
scanf("%d",&array1[i]);
min=array1[0];
max=array1[0];
for(i=0; i<size; i++)
{
if(array1[i]<min) min=array1[i]; if(array1[i]>max)
max=array1[i];
}
printf(" \nThe maximum element in array is %d",max);
printf("\nThe minimum element in array is %d",min);
}