1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include <cmath>
double pow1, pow3, pow4, pow5, pow6, pow7, pow8, pow9;
char exponent;
// ask to what power the user would like to raise the first number
if( cin, operation == '1');
cout <<"Please enter to what power (0-9) " << first_number << " should be raised: " << endl;
cin >> exponent;
// execute when the exponent requested is 0
if( cin, exponent == '0')
cout << first_number << " to the power 0 = 1" << ". " << endl;
// excecute when the exponent requested is 1
if (cin, exponent == '1')
pow1 = pow(first_number, 1);
cout << first_number << " to the power 1 = "<< first_number << ". " << endl;
// execute when the square operation is requested
if( cin, exponent == '2')
cout << first_number << " square " << " = " << first_number*first_number << ". " << endl;
// execute when the exponent requested is 3
if( cin, exponent == '3')
pow3 = pow(first_number, 3);
cout << first_number << " raised to the power 3 = " << pow3 << ". " << endl;
// execute when the exponent requested is 4
if( cin, exponent == '4')
pow4 = pow(first_number, 4);
cout << first_number << " raised to the power 4 = " << pow4 << ". " << endl;
// execute when the exponent requested is 5
if( cin, exponent == '5')
pow5 = pow(first_number, 5);
cout << first_number << " raised to the power 5 = " << pow5 << "." << endl;
// execute when the exponent requested is 6
if( cin, exponent == '6')
pow6 = pow(first_number, 6);
cout << first_number << " raised to the power 6 = " << pow6 << ". " << endl;
// execute when the exponent requested is 7
if( cin, exponent == '7')
pow7 = pow(first_number, 7 );
cout << first_number << " raised to the power 7 = " << pow7<< ". " << endl;
// execute when the exponent requested is 8
if( cin, exponent == '8')
pow8 = pow(first_number, 8);
cout << first_number << " raised to the power 8 = " <<pow8<< ". " << endl;
// execute when the exponent requested is 9
if( cin, exponent == '9')
pow9 = pow(first_number, 9);
cout << first_number << " raised to the power 9 = " << pow9 << ". " << endl;
|