+ 2

Two questions in C++ need help with.

1. Design a logic for a program That allows the user to enter 20 then display them in the reverse order of entry? 2. Modify the reverse display program so that the user can enter any amount of numbers up 20 until a sentinel value is entered?

4th Oct 2019, 7:48 PM
LaRena
LaRena  - avatar
7 ответов
+ 5
logic 1 cin>>n; //where n=20 while(n!=0) { cout<<n; n—; } explain logic 2 its not clear
6th Oct 2019, 10:50 AM
Divij Manik
Divij Manik - avatar
+ 2
Thank you to both of your suggestions, I will try to write the code using an array. I am taking my first programing class intro into programming 120. I can honestly say I am clueless when it comes to coding but I want to understand it and am eager to learn how!
5th Oct 2019, 3:45 PM
LaRena
LaRena  - avatar
+ 1
Have you tried to write the code? If yes then tell what problems you are facing.
4th Oct 2019, 7:58 PM
A͢J
A͢J - avatar
+ 1
Display 20 what? 20 ints? 20 chars? I can give you a hint. Use an array.
4th Oct 2019, 8:56 PM
Stephen Matthew
Stephen Matthew - avatar
+ 1
/* Enter two numbers This program lists all the numbers from the lowest entered to the highest entered in rows of ten */ #include <iostream> using namespace std; int main() { int v1,v2; cin>>v1>>v2; int lower,higher; if(v1<v2) { lower=v1; higher=v2; } else { lower= v2; higher= v1; } int i = 0; while(lower<=higher) { if(i<=9) { cout<<lower<< " "; i++; } else { cout<< endl<<lower<< " "; i=1; } lower++; } return 0; }
5th Oct 2019, 4:02 PM
LaRena
LaRena  - avatar
+ 1
thank u for the answer, Divij. sorry it took me so long to respond back.
22nd Oct 2019, 6:40 AM
LaRena
LaRena  - avatar
0
Besides solo learn, cplusplus.com and theCherno on youtube are great sources to learn C++. Cheers
5th Oct 2019, 8:09 PM
Stephen Matthew
Stephen Matthew - avatar