Question: counts how many times the number 5 appears in array called NumArray?
Can anybody help me with this problem??
I got 4 "5s" but i don't know if i understood the question correctly or not....does "55" counts as two 5s???
and if it does then how do i count that?
#include <iostream>
using std::cout;
using std::endl;
const int Max = 10;
int main ()
{
int NumArray [Max] = {3, 5, 10, 14, 25, 33, 41, 55, 88, 155};
int count = 0;
for (int i = 0; i < Max; i++) {
if (NumArray[i] == 5) {
count++;
}
}
cout<<"The number 5 appears " << count <<" times in the array."<<endl;
return (count);
}