my prof give me this problem but i have no idea how to do it . im new to programming . sorry for my bad english :D .
this is the problem :
Create a program written in c++ language that will prompt the user to input 10 numbers . Use control structure || or Iteration Statements for inputs.The program will identify whether the input is Even od Odd . Count and compute the sum of odd and even numbers .
#include <iostream>
#include <string>
int main()
{
// code goes here:
// 1. Prompt the user to input 10 numbers
// (Hint: Use control structure || or Iteration Statements for inputs )
// 2. Identify whether the input is Even or Odd
// 3. Count
// 4. Compute the sum of odd and even numbers
}
@OP, tell us how you'd solve a problem using pen and paper if this weren't a programming class, but like a philosophy class or some math logics class. Ignore the fact that your professor is telling you to iterate or use logical and/or. Forget you've even heard of the term, "c++". What would you write, like as an essay, if your professor said, "tell me how you could tell, from 10 different numbers, which ones are even and which ones are odd"?
I only had a quick look and it looks pretty good. A couple of questions:
1. Have you tested it? Make sure your prof can work it.
2. I don't know whether you have studied arrays yet but you can simplify your code a lot especially if you combine arrays with a control loop - while, for etc. Maybe that's a refinement for the future.
Cheers and thks for getting back :)
PS I just gave it a test run. It works - well done!