/* * Create by Drake Vidkjer on 10/1/15 * Modified on 10/1/15 * Version .1 * Print out limits of numbers and convert inputed number to different bases */ #include #include using namespace std; void convertBin(int); void convertOctHex(int); void printMaxMin(); int askNum(); int main() { //Define some needed variables int num = 0; //ask user for number num = askNum(); //print out conversion to Octal and Hex convertOctHex(num); //print number in binary convertBin(num); //End program return 0; } void convertBin(int usnum) { //convert number to binary cout << "Number in binary: "; cout << usnum/8; usnum = usnum - (usnum/8) * 8; cout << usnum/4; usnum = usnum - (usnum/4) * 4; cout << usnum/2; usnum = usnum - (usnum/2) * 2; cout << usnum/1 << endl; usnum = usnum - (usnum/1) * 1; } void convertOctHex(int num) { //Convert number to hex and octal cout << "Number in octal: "; cout << oct << num << endl; cout << "Number in hex: "; cout << hex << num << endl; } void printMaxMin() { } int askNum() { int usnum = -1; //Take in number from user while(usnum > 15 || usnum < 0) { cout << "\nEnter a number 0-15: "; cin >> usnum; //Tell user if number isnt valid if(usnum > 15 || usnum < 0) { cout << "Sorry, not a valid number" << endl; } } return usnum; }