1. Read 10 integers from the keyboard in the range 0 - 100, and count how many of them are larger than 50, and display this result.
#include<iostream>
using namespace std;
int main()
{
int array[10];
int integers_larger_50 = 0;
cout << "Enter 10 integers in the range 0 - 100:";
for (int i = 0; i < 10; i++)
{
cin >> array[i];
cout << array[i];
if (array[i] > 50)
integers_larger_50++;
}
cout << "The number of integers is larger than 50: " << integers_larger_50 << endl;
system("pause");
return 0;
}
Comments
Leave a comment