/* * 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; int main() { int x = 0; //Define some needed variables int usnum = -1; //Print out max and mins of unsigned and signed #'s and print cout << "Integer maximum and minimum:" << endl; cout << INT_MAX << endl; cout << INT_MIN << endl; cout << "\nUnsigned integer maximum:" << endl; cout << UINT_MAX << endl; cout << "\nShort maximum and minimum:" << endl; cout << SHRT_MAX << endl; cout << SHRT_MIN << endl; cout << "\nUnsigned short maximum:" << endl; cout << USHRT_MAX << endl; cout << "\nLong maximum and minimum:" << endl; cout << LONG_MAX << endl; cout << LONG_MIN << endl; cout << "\nUnsigned long maximum" << endl; cout << ULONG_MAX << endl; //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; } } //Convert number to hex and octal cout << "Number in octal: "; cout << oct << usnum << endl; cout << "Number in hex: "; cout << hex << usnum << endl; //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; if (x=2) { cout << "x=2 works" << endl; if (x == 0) { cout << "x still = 0" << endl; } } //End program return 0; }