-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathThreeDigit.cpp
More file actions
90 lines (56 loc) · 1.47 KB
/
ThreeDigit.cpp
File metadata and controls
90 lines (56 loc) · 1.47 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
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 //delete the digit so its easier to read- JT
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";
}
while( x < 30){
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
}