Need Help

I need help with a loop program. I am using a PDF file called "jumping into C++" - By Alex Allain and this is the practice problem

"3. Write a program that computes a running sum of inputs from the user, terminating when the user gives an input value of 0"

I'm pretty sure it's supposed to be a do-while loop but that's only if I really do understand what I'm being asked to make.

Please help I made an account to this site specifically to answer this question.
-Thank you
Post the code you've tried so far (please Format it, look for the <> symbol when posting.)

You are right by the way, a do-while loop is perfect for this assignment.
I spent a few minutes doing this and when I run it I can't even get the while loop to work (if I even need it??)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <string>

using namespace std;

int main ()
{
    string num1;
    string num2;
    string num_total = num1 + num2;

    do
    {
        cout << "Type in first number to add- ";
        cin >> num1;

    }while(num1>0);
return 0;

while (num2>);
{
    cout << "Type in next number to add- ";

    cout << "total" << "=" << "num_total";
}

}


come on guys.
Learn c++,that was easy program.


anyway


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>

using namespace std;


int main()
{

    int input;
    int sum;

    cout<<"Give your first number:";
    cin>>input;
    sum=input;

    while(input!=0)
    {
        cout<<"Give your next number:";
        cin>>input;
        sum+=input;

    }

    cout<<"The sum of your numbers are:"<<sum<<endl;

    return 0;
}


I coded in 5 minutes.it wasn;t difficult.
Anyway if need help give me your skype for more information.
Thank you haha. I seem like an idiot for it but I actually had no idea what it was wanting me to program.
Topic archived. No new replies allowed.