Question: IN C ++ PLEASE!!! Write a program that asks the user for integers; stop when the user enters a zero (0). For each nonzero number,

IN C ++ PLEASE!!! Write a program that asks the user for integers; stop when the user enters a zero (0). For each nonzero number, count how many even, odd, positive and negative values are entered. Display the results as shown below:

1

2

3

4

5

6

7

8

-9

-10

-11

-12

0

You entered:

6 even numbers

6 odd numbers

8 positive numbers

4 negative numbers

So far, this is my code:

#include #include using namespace std; int main () {

int userEven = 0; int userOdd = 0; int userPos = 0; int userNeg = 0; int num;

cin >> num; cout << num << endl;

while (num != 0) { if ((num % 2) == 0) { userEven++; } else { userOdd++; } break; if (num < 0) { userNeg++; } else { userPos++; } }

cout << "You entered: " << endl; cout << userEven << " even numbers" << endl; cout << userOdd << " odd numbers" << endl; cout << userPos << " positive numbers" << endl; cout << userNeg << " negative numbers" << endl; return 0; }

This is not coming out how my example was above. Please let me know if you can help! :)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!