develop a program that continues to read data values as long as they are not decreasing. The program should stop reading whenever a number smaller than the preceding one is entered.
Study this code, test it, make sure that you understand it, play around with it (try changing it and see what happens);
and then write it on your own (ideally, without looking at this code).
#include <iostream>
int main()
{
int number ;
// read in the first numbers
std::cout << "enter a number: " ;
std::cin >> number ;
int preceding_number = number ; // for the second number, the first number is the preceding number
// keep reading numbers one by one as long as the number that was read is not less than the preceding number
while( std::cout << "enter a number not less than " << preceding_number << ": " &&
std::cin >> number && number >= preceding_number )
{
preceding_number = number ; // the preceding number is now the number that was just read
}
std::cout << "quitting: you did not enter a number not less than " << preceding_number << '\n' ;
}