#include <iostream>
int main() {
/* signed */ int number;
unsigned /* int */ counter, counter2;
std::cout << "Enter 10 integers in the range 0-100 and EOF\n";
counter = 0, counter2 = 0;
std::cin >> number;
while (!std::cin.eof() && !std::cin.fail() && counter < 10
&& number >= 0 && number <= 100) {
counter += 1;
if (number > 50) {
counter2++;
}
std::cin >> number;
}
if (counter == 10 && std::cin.eof()) {
std::cout << counter2 << " of the numbers are larger than 50\n";
} else {
std::cout << "The input contents were unexpected\n";
}
}
Comments
Leave a comment