+ 2
I don't know c++ but I will give you the basic explanation that I hope you will understand. 1)Ask the user to input a number 2)While loop that repeats as long as the number is non-negative, for example: while(userInput >= 0) *This ensures the loop will stop executing when the number is less then 0 3)Inside the while loop you need an if statement to test whether the number is odd. If the number isn't odd then it has to be even, that's when you use else statement. For example if(userInput % 2 == 1) oddNumbers++; else evenNumbers++ 4)Ask the user for new input 5)Close the while loop here. *)Keep in mind that you have to define oddNumbers and evenNumbers outside the while loop and set their value to 0
3rd Apr 2017, 6:59 PM
Dextozz - avatar