I am new to C++. I am trying to read through the array of numbers and count the amount of numbers in the array that are equal to the user entered number. I am not sure what to do next to get it to make number = number1 and count it. I hope this makes sense. Thanks.
#include <iostream>
using namespace std;
int main()
{
int number[20] = {80, 52, 25, 71, 56, 90, 87, 10, 32, 80, 2, 67, 73, 50, 52, 73, 72, 20, 86, 99};
int numberCount = 0;
int number1 = 0;
cout << "Enter a number between 0 and 100: ";
cin >> number1;
while(number1>100 || number1<0)
{
cout << "Invalid number,enter again" << endl;
cin >> number1;
}
for(i = 0; i < 20; i = i + 1)
{
}
system("pause");
return 0;
}
There’s a function in the standard library for this, in the
<algorithm>header: