Write a program to input 10 integers and find and print the greatest and the smallest number among 10
numbers.
Input: 13, 33, 7, 327, 775, 709, 4513, 551, 49, 980
Output: Greatest Number is 4513
Smallest Number is 7
Answers
Answered by
3
Step-by-step explanation:
include <stdio.h>
int main() {
int a[10];
int i;
int greatest;
printf("Enter ten values:");
//Store 10 numbers in an array
for (i = 0; i < 10; i++) {
scanf("%d", &a[i]);
}
//Assume that a[0] is greatest
greatest = a[0];
for (i = 0; i < 10; i++) {
if (a[i] > greatest) {
greatest = a[i];
}
}
printf("
Greatest of ten numbers is %d", greatest);
return 0;
}
Similar questions