المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Program Which: Takes numbers from a user, and sum's them.



C++ Programming
01-20-2010, 10:51 PM
Hello all,

I am working on my homework for my C++ programming class and I am hitting a brick wall. Everywhere I look online does not seem to have any information in which I can apply to my program. I am supposed to use a "while" loop which I am, and thats working.

The part which is not working is the users input should add it to the previous entry, and after the user types "0" it will display the sum on the screen. I have looked at the following references to try and make sense of things:
http://www.cplusplus.com/reference/std/numeric/partial_sum/[^ (http://www.cplusplus.com/reference/std/numeric/partial_sum/)]
http://www.cplusplus.com/reference/std/numeric/accumulate/[^ (http://www.cplusplus.com/reference/std/numeric/accumulate/)]
http://frank.mtsu.edu/~csci117/manual/lab7/lab7.html[^ (http://frank.mtsu.edu/~csci117/manual/lab7/lab7.html)]
I am trying very hard to understand this, but I can not find a good online reference of the libraries. www.cplusplus.com is very good but dosent have the info I need, or more than likely I can not find it.

But here is the code to which I am trying to correct:
#include
#include

using namespace std;

int main()
{

// Global Variables
int userinput;
int sum = 0;
sum = sum + userinput;


// Start While loop
while (userinput != 0)
{
// Prompt User for input
cout > ++userinput ;

}
cout