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
@@ -1,14 +1,26 @@
/* Overall changes:
Added date
Comments on printing ascending, descending, and neither to clarify what happens
Altered the ints to decrease the amount of lines
Comments on cin and pause to clarify what happens
Added comments for what is included in the libraries
*/

/*
Ved Nigam-Period 3-Computer Science 1
Ved Nigam-Period 3-Computer Science 1 October 5, 2017
In this assignment, we will split a 3 digit number into 3 different numbers with the same characters as the 3 digit number. We will then run a tets to see if the numbers are
"Descending," "Ascending," or "Neither."
*/
// Added date

//Libraries
#include <iostream>
#include <conio.h>
#include <iostream> // gives access to cin, cout, endl, <<, >>, boolalpha, noboolalpha
#include <conio.h> // gives access to _kbhit() and _getch() for pause()
// Added comments

//Namespaces
using namespace std;

//Functions
void pause() {
cout << "Press Any Key to Continue . . .";
Expand All @@ -18,26 +30,35 @@ void pause() {
}

void main() {
int x;
int a;
int b;
int c;

cout << "Enter a 3 Digit Number . . ." << endl;
cin >> x;
c = x % 10;
b = x / 10 % 10;
a = x / 100;

if (a > b && b > c) {
cout << "Descending" << endl;
}
else if (a < b && b < c) {
cout << "Ascending" << endl;
}
else {
cout << "Neither" << endl;
for (int i = 0; i < 30; i++) {
int x;

cout << "Enter a 3 Digit Number . . ." << endl;
cin >> x; // 'x' is the variable that stores the three digit number that the user types in.
// Added comments

int c = x % 10; // Isolates the digit in the 1's place
int b = x / 10 % 10; // Isolates the digit in the 10th's place
int a = x / 100; // Isolates the digit in the 100th's place
// Altered : Placed int c, int b, and int a in one area

if (a > b && b > c) {
cout << "Descending" << endl;
} // If the digits of 'x' are presented in a descending order from left to right, print 'descending'.
// Added comment for what it does
else if (a < b && b < c) {
cout << "Ascending" << endl;
} // If the digits of 'x' are presented in a ascending order from left to right, print 'ascending'.
// Added comment for what it does
else {
cout << "Neither" << endl;
} // If the digits of 'x' aren't present in either a descending or ascending order from left to right, print 'neither'
// Added comment for what it does

pause(); // Ends function, prints "Press any key to continue..."
// Added comment for what it does
}
pause();
}