1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
//Ch11AppE06.cpp
//Displays the number of students earning a specific score
//Created/revised by <your name> on <current date>
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
//declare array
int count = 0;
int searchFor = 0;
int scores[20] = {90, 54, 23, 75, 67, 89, 99, 100, 34, 99,
97, 76, 73, 72, 56, 73, 72, 20, 86, 99};
cout << "Enter a score from 0 to 100: ";
cin >> searchFor;
for (int x = 0; x < 20; x += 1)
if (scores[x] != searchFor)
count += 1;
cout << "Scores: " << count << endl;
return 0;
} //end of main function
|