Loop hole in my Loop Structure

Hello out there! :-) I am very new to C++ (and computer coding in general), but I have decided to take on the challenge. I am trying to read up on the C++ language and experiment with writing programs.

My current task in question is to write a program using a loop structure (while, do while, etc.) that is capable of reading five whole numbers (can be positive, negative, or zero) and that will perform the following tasks:

1.) Output the sum of all the numbers greater than one (>1),
2.) Output the sum of all the numbers less than negative one (<-1),
3.) and output the sum of all the numbers.
4.) When the session is through, the program should ask the user whether or not they desire to continue.

Thus far, I've started out with the following:
#include <iostream>
using namespace std;

int main()
{
int five_whole_numbers

do
{
cout << "Enter five whole numbers in any order and then press return\n";
cin >> five_whole_numbers;

} while



I've stopped here, because I have no idea if I'm even on the right track or not. How can I approach this problem? I need to figure out how to get the program to solve these equations and to give the user the option of continuing or not. Would that part require an If/else statement? Also, what should I declare at the beginning of the program?

Any thoughts/help/tips/hints would be greatly appreciated!
Last edited on
Hello,

As a first advice I think you should get some C++ manual, book or something that has a thorough approach of C++. I am not an expert in C++ but from the question you ask I think you haven't read a single complete manual of C++, right? You are not going to learn C++ this way. In a manual or book issues are covered sequential and reveals aspects you didn't even know existed, so at least give a solid base to learn the language.

Anyway you need to declare variables int for storing your numbers. Put some if to check whether to use it in your sums (need variables for them also) and finally use an if to examine the intension of the user. There a lot of approached for this problem but you must experiment yourself.
I couldn't really get what you want to do with the user entered 5 numbers. Anyway this might help you: http://recurseit.blogspot.com/2011/09/sum-of-natural-numbers-up-to.html
Its a code for adding a series.
Thanks, everyone! :-) I actually do have a C++ manual. I've read the first two chapters so far. (They are quite long chapters.)

Thanks for the tips & the link, too! ^_^
Topic archived. No new replies allowed.