-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathThreeDigit.cpp
70 lines (40 loc) · 1.06 KB
/
ThreeDigit.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
Angela Liu and Sofia Lalani - October 5th 2017, Period 4
Ascending Descending
Very Basic Coding using integers
*/
// Libraries
#include <iostream> // gives access to cin, cout, endl, <<, >>, boolalpha, noboolalpha
#include <conio.h> // gives access to _kbhit() and _getch() for pause()
// Namespaces
using namespace std;
// Functions()
void pause() {
cout << "Press any key to continue . . .";
while (!_kbhit());
_getch();
cout << '\n';
}
// MAIN
void main() {
int number; // X is a three digit number
int digit_a; // hundreds place
int digit_b; // tens place
int digit_c; // ones place
cout << "Choose a 3 Digit number:" << endl;
cin >> number;
digit_a = number / 100;
digit_b = (number % 100) / 10;
digit_c = number % 10;
if (digit_a > digit_b && digit_b > digit_c) {
cout << "descending";
}
else if (digit_a < digit_b && digit_b < digit_c) {
cout << "ascending";
}
else {
cout << "neither";
}
pause();
pause(); // pauses to see the displayed text
}