Create a program that stores 10 integers. Print the maximum and the minimum integer found in the array.
#include <stdio.h>
int main()
{
int n=10,i;
int numbers[10];
int maximum =0;
int minimum =0;
for (i = 0; i < n; i++)
{
printf("Enter number %d: ", (i+1));
scanf("%d", &numbers[i]);
}
maximum=numbers[0];
minimum=numbers[0];
for (i = 1 ; i <n; i++)
{
if(numbers[i]>maximum){
maximum=numbers[i];
}
if(numbers[i]<minimum){
minimum=numbers[i];
}
}
printf("\nThe minimum integer is: %d\n", minimum);
printf("The maximum integer is: %d\n", maximum);
getchar();
getchar();
return 0;
}
Comments
Leave a comment