Hello everyone, How to do this how do i start

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.
closed account (48T7M4Gy)
Perhaps a start by writing some pseudocode?
Yah
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).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#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' ;

}
Topic archived. No new replies allowed.