Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions Program Problem 3/Program Problem 3/Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Three Digit Ascending and Descending Selection

#include <iostream>
#include <conio.h>
#include <Windows.h>



using namespace std;
Expand All @@ -22,31 +22,47 @@ void pause() {
void main() {
int three_digit_number;


cout << "Enter a three digit number, ";
Sleep(2000);
cout << "please. : ";
cin >> three_digit_number;


int x = three_digit_number;
int A = x / 100;
int B = (x / 10) % 10;
int C = x % 10;
//don't try to change the variable name, it could confuse you later on; stick to the specific variable name you've already given
int A = three_digit_number / 100;
int B = (three_digit_number / 10) % 10;
int C = three_digit_number % 10;


if (A < B && B < C) {
cout << "Ascending..." << endl;
Sleep(2000);
}
else if (A > B && B > C) {
cout << "Descending..." << endl;
Sleep(2000);
}
else {
cout << "Neither..." << endl;
Sleep(2000);
}

for (int i = 1; i < 30; i++) {
cout << "Enter a three digit number, ";
cout << "please. : ";
cin >> three_digit_number;

int A = three_digit_number / 100;
int B = (three_digit_number / 10) % 10;
int C = three_digit_number % 10;

if (A < B && B < C) {
cout << "Ascending..." << endl;
}
else if (A > B && B > C) {
cout << "Descending..." << endl;
}
else {
cout << "Neither..." << endl;
}
}


pause();
}
}