C program to find out maximum and minimum numbers in C.
C Program to find out Maximum Numbers
// C program by taking user input and print the maximum values.
#include<stdio.h>
int main()
{
int num[50], n, i;
printf("How many numbers: ");
scanf("%d",&n);
for(i=0; i<n; i++)
{
scanf("%d",num[i]);
}
int max = num[0];
for(i=1; i<n; i++)
{
if(max < num[i])
max = num[i];
}
printf("Maximum is %d\n", max);
return 0;
}
C Program to find out Minimum Numbers
#include<stdio.h>
int main()
{
int num[100], n, i;
printf("How many Numbers: ");
scanf("%d",&n);
for(i=0; i<n; i++)
{
scanf("%d",num[i]);
}
int min = num[0];
for(i=1; i<n; i++)
{
if(min > num[i])
min = num[i];
}
printf("Minimum number is %d", min);
return 0;
}