I need help with this program. I have to read and display whole numbers as long as the last input value is greater than or equal to the previous input value.
(Input: "1 2 5 4 8" Output: "1 2 5")
*I have to use a while loop
This is what I have so far. I have no clue if I'm even on the right track. Please help.
In lines 8 and 9, you store the first number input into prev and the second number into cur.
On line 10, you say as long as cur >= prev, keep doing lines 12 and 13. Everything's OK so far.
But then on line 12, you overwrite prev with a new number input and cur with another number input. What if the 4 inputs so far were 10, 10, 0, 0. Wouldn't that mean you're saving the second 0 to cur when you're not supposed to?
Also, you need to output the numbers that were input. You should probably output the first number (stored in prev) before the loop, and then output the number in cur inside the loop, before any input operations.