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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Three_Digit_Ascend_Descend_Selection : *

Determining order of digits

Modified by Christopher Hartsfield and Jaren Duffield

*/

#include <iostream>
Expand All @@ -20,29 +22,37 @@ void pause() {
cout << '\n';

}
void main() {
int main()
{
int i = 1;
while (i < 31)
{
int x;
cout << "Press any positive three digit number";
cout << "Press any positive three digit number ";
cin >> x;
int a = (x/100) % 10;
int a = (x / 100) % 10;
int b = (x / 10) % 10;
int c = x % 10;
bool ascending = a!= b && b!= c;
bool ascending = a != b && b != c;
bool descending = ascending;
if(a > b)
ascending = false;
else
descending = false;
if(b > c)
ascending = false;
else
descending = false;
if(ascending)
cout << "Ascending \n";
else if(descending)
cout << "Descending \n";
else
cout << "Neither ";

pause();
}
if (a > b)
ascending = false;
else
descending = false;
if (b > c)
ascending = false;
else
descending = false;
if (ascending)
cout << "The number " << x << " is ascending \n";
else if (descending)
cout << "The number " << x << " is descending \n";
else
cout << "The number " << x << " is neither ascending or descending \n";
i++;
_getch();
}
return 0;
}