This is a simple problem.
The small error that you are doing is out making an endless loop.
Try doing this instead:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include <iostream>
int main()
{
int sum = 0, value;
while (std::cin >> value)
{
sum += value;
std::cout << "Sum is: " << sum << std::endl;
}
return 0;
}
|
This is what u are actually trying to do... I believe.
The problem with your original code is that you are setting the program into an endless loop. Between the "while part".
Generally, a while structure goes like this:
1 2 3 4
|
While (condition)
{
Code executed
}
|
Because in your condition, it is simply telling to go get a value (cin >> value), it will always continue with the "while" part and enver go onto line 11 (std::cout << "Sum is: " << sum << std::endl;).
Hope this helps, if u have any more questions, please ask, however, I must warn u, I'm not a C++ expert, but a fellow beginner just like yourself.