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
78 changes: 42 additions & 36 deletions program problem 3/program problem 3/Alan_lee program problem 3.cpp
Original file line number Diff line number Diff line change
@@ -1,47 +1,53 @@
/*
/*
Rahul Singh and Alan Lee - 1st period
Program Problem 3
Using a 3 digit number to put create separate varibles
*/

// Libraries
#include <iostream> // gives access to cin, cout, endl, <<, >>, boolalpha, noboolalpha
#include <conio.h> // gives access to _khbit, (), and _getch () for pause ()
// namespace
#include <iostream>
#include <conio.h>
#include <math.h> //important for the functions to solve the math

//Namespaces
using namespace std;
//functions ()

//Functions()
void pause() {
cout << "choose 3 ascending numbers . . .";
while (!_kbhit ());
_getch ();
cout << '\n';
cout << "Press any key to continue...";
while (!_kbhit());
_getch();
cout << '\n'; //helps with the pause
}
// main
void main() {
int x; //store some 3 digit number in x
cout << "Enter 3-digit number";
cin >> x;
int c= x % 10;
int b= (x/10) % 10;
int a= (x/100);
bool ascending = a != b && b != c;
bool descending = ascending;

if(a > b)
ascending = false;
else
descending = false;
// Variables
int x; //the three digit number taken in
int a; //the first number; the hundreds place
int b; //the second number; the tens place
int c; //the third number; the ones place
int y; //integer that helps with while function


if (b > c)
ascending = false;
else
descending = false;

if(ascending)
cout <<"Ascending \n";
else if(descending)
cout << "Descending \n";
else
cout << "Neither";
}
// MAIN
int main() {
int y = 1;
while (y < 31) //makes it loop 30 times
{
cout << "Enter in a three digit number. \n";
cin >> x;
//finding all the digits
int a = x / 100;
int b = (x - a * 100) / 10;
int c = (x - a * 100 - b * 10);
//main functions
if (a < b && b < c)
cout << "Ascending \n";
else if (a > b && b > c)
cout << "Descending \n";
else {
cout << "Neither \n";
y++; //is adding more on to the loop
_getch();
}
}
return 0; //goes to the beginning of the loop
}