When running the program given, it is supposed to give the output bewlow. However, the program
contains erros that prevent it from compiling and/or running. Correct the program so that it works
properly.
The output:
Please enter 10 integers, positive, negative, or zeros.
The numbers you entered are:
2
7
-4
-3
0
7
4
0
-9
-4
There are 6 evens, which includes 2 zeros.
The number of odd numbers is: 4
#include <iostream>
usingnamespace std;
constint LIMIT = 10;
int main ()
{
float counter;
int number;
int zeros;
int odds;
int evens;
cout << "Please enter " << Limit << " integers, "
<< "positive, negative, or zeros." << endl;
cout << "The numbers you entered are:" << endl;
for (counter = 1; counter <= LIMIT; counter++)
{
cin << number;
switch (number / 2)
{
case 0:
evens++;
if (number = 0)
zeros++;
case 1:
case -1:
odds++;
}
}
cout << endl;
cout << "There are " << evens << " evens, "
<< "which includes " << zeros << " zeros."
<< endl;
cout << "The number of odd numbers is: " << odds
<< endl;
return 0;
}
Put the code you need help with here.
what are you having trouble with? This looks like the original code you should correct.
for one thing, it says it will print what you entered before you entered it. For another, number/2 won't give you an even odd test. There is no default case. case 1 makes no sense at all. try math:
11/2 = 5 (integer math).
switch (5)
is it 0? no.
is it 1? no
is it -1? no
what do you do, then??
Your compiler should give you the lines on (or, occasionally, near) which there are errors.
Exactly my thoughts. If your compiler is bad, try one of the online ones, like at https://repl.it/languages/cpp , which I use alllllll the time when helping people here ;D This one gives you suggestions like "did you mean X?"