1. ## Help accumilative variables

Ok I'm tryin to add numbers together but just add the total of negative and then the total of positive numbers.

Code:
```value = -2.3;
while (value <= 2.9) {
cout << value << " ";
value = value + .4;```
Now after this I'm tryin to just add the negative and then the positive but I am not sure. I will have the negative variable as neg and the positive variable as pos. I am not sure how to make it only read the neg/pos numbers. I know that greater or lesser but just don't know how to set it up. 2. I know everytime thru the loop add the next value to the accumulator variable, switching to the other accumulator variable after you cross 0, but not sure how to write this? 3. could someone help me? 4. This would seem to be what if-statements were born to do (if positive do this otherwise do that). 5. Originally Posted by tabstop This would seem to be what if-statements were born to do (if positive do this otherwise do that).
I know it is an if statement but don't know how to write it. Could you help me? 6. And also I am very very new to this. 7. Originally Posted by walkonwater I know it is an if statement but don't know how to write it. Could you help me?
well you have the logic of the code down correct and you know what you need to do. simply write it out on paper in pseudo code first, post what you come up with and we'll take it from there. A little effort on your part goes a long way. 8. the thing I don't know is if I have to create a new int. 9. You need to break it down into logical chunks of what needs to happen then put those chunks together using if statements.

hint:
you've assigned value as -2.3 so that will need to be looped until it hits 0 then you need to do the other loop to it.

Refer to your source on using if statements. Your best bet is to write as much as you can and then post it, you'll get more help that way  10. Code:
```if (0 < value)
cout << I am not sure how to add it right here```
I am not even sure if this is right. I would just think you do this. 11. Originally Posted by walkonwater Code:
```if (0 < value)
cout << I am not sure how to add it right here```
I am not even sure if this is right. I would just think you do this.
The cout will happen if the statement in parentheses is true, i.e., if 0 < value. I leave it to you to determine (a) if 0 < value, whether value is positive or negative and then (b) how to use = and + in some order to make the addition happen. 12. well I know this:

Code:
```if (0 < value)
cout << not sure what to put here.
else
cout << not sure what to put here``` 13. Try putting your original code in there. 14. value = -2.3;
while (value <= 2.9) {
cout << value << " ";
value = value + .4;
if (0 < value)
cout << not sure what to do
else
cout << not sure what to do
I am not sure if above is right however 15. If you can add to value (as evidenced by the line "value = value + .4") why can't you add to pos and neg? Popular pages Recent additions 