Your program should ask the user for a sequence of numbers until the user inputs 0 (zero) and then the program should print the sum of positive numbers that the user input.
I am not allowed to use functions, arrays, or constructs that I haven't studied. This will probably be limited to a "Do-While" and "If" statement.
I believe I am close, but I am confused about what operators to use to create a sum. The user may input as many numbers as he/she wants - so it is not a defined set of numbers.
// Finds the Sum of Numbers
// Brian Kircher
// 01/30/2013
#include <iostream>
usingnamespace std;
int main(void){
int sum=0;
int numbers;
do{
cout << "Input number [0 to stop program]: ";
cin >> numbers;
if ( numbers > 0) ;
}while(numbers != 0);
cout << "The maximum number is: " << sum << endl;
}
Strictly speaking, you should make this dependent on the "if" statement, but since adding zero to the total doesn't change the result, you could even miss that out.
The do-while looks reasonably ok.
The text on line 31 says "maximum number" which doesn't agree with your description of the problem.