Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need a simple c++ program which print sum of negative numbers, sum of positive even numbers, sum of positive odd numbers from a list of numbers entered by the user..
Posted
Updated 15-Jan-15 7:42am
v2
Comments
CHill60 15-Jan-15 12:35pm    
What have you tried?
Where are you stuck?

1 solution

Collect user input in a std::vector then iterate over the vector items updating the requested sums as appropriate.
Hint: (n % 2) expression result is 0 if n is even, 1 if n is odd.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900