I am working on displaying the amount ofodd numbers in this array. It always says there is 5. That is not correct. When I use the debug it shows that it is placing a different value in the myArray and using that to determine the amount of odd numbers. Please someone take a look.
#include <iostream>
using std::cout;
using std::endl;
const int MAX = 10;
int myArray[MAX] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 11};
int odd = 0;
int main()
{
for (int i = 1; i < MAX; i++)
{
if ((i%2)==1)
odd++;
}
cout << "Number of odd integers: " << odd << endl;
return 0;
}
<< moderator edit: added code tags: [code][/code] >>