fork download
#include <iostream>

int main()
{
  int sum = 0, value = 0;

  // read until end-of-file, calculating a running total of all values read
  while (std::cin >> value)
    sum += value;

  std::cout << "Sum is: " << sum << std::endl;
  return 0;
}
Success #stdin #stdout 0.02s 2728KB
stdin
3 4 5 6 
stdout
Sum is: 18