user input, if else while loops

Write a C++ program that does the following.

1. Asks the user to enter some positive integers.

2. Reads the positive integers from the user.

3. Stops reading the positive integers once a non-positive integer is entered.

4. Reports the sum of all the positive numbers that it read (exclude the negative number from the sum).

For example:

Enter some positive integers: 1 2 3 -10

The sum is: 6
This is the first one that i did and i have tried several different methods with if, while etc and i cant seem to get it.

Write a C++ program that does the following:

1. Asks the user to enter a positive integer z.

2. Reads z from the user. If z is not legal, the program repeatedly makes the user type in another value until a legal value of z has been entered.

3. Prints z in reverse order, digit by digit, separated by spaces, and then prints their sum.



For example:

Give me a positive integer: -1

Give me a positive integer: 19683

3 8 6 9 1 sum to 27

I dont know how to reverse the numbers and ask for a sum?
You should read the FAQs we all are here to help but we cannot do homework perhaps you should edit this thread an add the code of what you have tried so far, and the we could be more helpfull.

i think in the first one that you will need a for asking for random number for the user to input and save them all in an array [] and then with another for with an if inside you could manipulate them easily call the second one might be the bubble method but i didnt quite understand what you are needed to do if you upload your code i could help .
to do reserve do this:
%10
Topic archived. No new replies allowed.