/***************************************************
Maximum Number
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 largest 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** max_seen, k;
cin >> k;
max_seen = k;
cin >> k;
// Loop while the user enters more data
**while** (k >= 0)
**{**
// check whether k is biggest so far
**if** (k > max_seen)
max_seen = k;
// read next value
cin >> k;
**}**
// write out result
cout << "The largest number was "
<< max_seen << endl;
**return** 0;
**}**