Do-While Loops - ALMOST COMPLETE

This program should work as follows (and it does work - almost):

Input sequence of integers (zero to stop): -4 3 -20 10 45 100 -1 0
The sum of positive numbers is: 158

The program should IGNORE negative numbers, and not add or subtract them.

Do I need to do this in another If statement?

Thanks



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Finds the Sum of Numbers
// 
// 01/30/2013

#include <iostream>
using namespace std;

int main(void){ 

  int sum=0; 
  int numbers;

  do{
    cout << "Input number [0 to stop program]: ";
    cin  >> numbers;

	
    if ( numbers > 0) ;
	 sum += numbers;
  }while(numbers != 0);

  cout << "The sum total is: " << sum << endl;

}
try removing the " ; " right after your if statement :)
Topic archived. No new replies allowed.