/***************************************************
Sum of numbers
Write a program that reads in positive integers from
the user, each separated by a space, and the whole
terminated by a negative number (e.g. 3 22 10 -2),
and returns the sum of the numbers entered (not
including the terminated negative number!).
***************************************************/
**#include <iostream>**
**using** **namespace** std;
**int** main()
**{**
// initialization
cout << "Enter numbers separated by spaces"
<< " and terminated with a negative number."
<< endl;
**int** sum, k;
sum = 0;
cin >> k;
// Loop while the user enters more data
**while** (k >= 0)
**{**
sum = sum + k;
cin >> k;
**}**
// write out result
cout << "The sum is " << sum << endl;
**return** 0;
**}**