Originally Posted by
Mrzach3590
Can't get this code here to work tried everything I can think of and looked at the FAQ. Should add up multiple variables.
Code:
#include <iostream>
int main(void)
{
int sum = 0, value;
while (std::cin >> value)
sum += value;
std::cout << "Sum is: " << sum << std::endl;
std::cin.get();
std::cin.ignore();
return 0;
}
Ok, theres the original messed up code, and heres the code that finally worked...
Code:
#include <iostream>
using namespace std;
int main(void)
{
int sum = 0, value;
while (std::cin >> value) {
sum += value;
std::cout << "Sum is: " << sum << std::endl;
}
std::cin.ignore();
std::cin.get();
return 0;
}