From 5a238e3a70019fb39e046869a08c8e7e951fc833 Mon Sep 17 00:00:00 2001 From: ConCougar <31855580+ConCougar@users.noreply.github.com> Date: Thu, 12 Oct 2017 10:35:39 -0500 Subject: [PATCH] Assignment 4 made comments and created a loop where user can enter 30 numbers to check if ascending, descending or neither --- .../Program Problem 3/Problem3.cpp | 63 +++++++++++++------ 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/Program Problem 3/Program Problem 3/Problem3.cpp b/Program Problem 3/Program Problem 3/Problem3.cpp index 08b01ac..b2adfb1 100644 --- a/Program Problem 3/Program Problem 3/Problem3.cpp +++ b/Program Problem 3/Program Problem 3/Problem3.cpp @@ -24,7 +24,7 @@ void pause() { cout << "Press any key to continue . . ."; - + while (!_kbhit()); @@ -37,32 +37,59 @@ void pause() { void main() { - int x; + int x; // make variable names more specific int A; int B; int C; - cout << "Give me a 3-digit number: "; - cin >> x; + cout << "Give me a 3-digit number: "; + cin >> x; + + + C = x % 10; + B = (x / 10) % 10; + A = (x / 100); + + if (A > B && B > C) { + cout << "Descending" << endl; + } + + else if (C > B && B > A) { + cout << "Ascending" << endl; + } + + else { + + cout << "Neither" << endl; + } - C = x % 10; - B = (x / 10) % 10; - A = (x / 100); - if (A > B && B > C) { - cout << "Descending" << endl; - } - - else if (C > B && B > A) { - cout << "Ascending" << endl; - } + for (int i = 1; i < 30; i++) { + cout << "Give me a 3-digit number: " << endl; + cin >> x; - else { - cout << "Neither" << endl; - } + C = x % 10; + B = (x / 10) % 10; + A = (x / 100); + + if (A > B && B > C) { + cout << "Descending" << endl; + } + + else if (C > B && B > A) { + cout << "Ascending" << endl; + } + + else { + + cout << "Neither" << endl; + } + } + pause(); // pauses to see the displayed text -} \ No newline at end of file +} +}