The do-while loop is a test at the bottom loop and is useful for cases where a value used in the loop test is entered or calculated in the loop body. Compared to the while-loop version, the do-while version is smaller because it requires one less prompt and read. Overall, the following code is clean and straightforward.
int max3()
{
int max = -1;
int number;
do
{
cout << "Please enter a number: ";
cin >> number;
if (number > max)
max = number;
} while (number >= 0);
return max;
}