Raising the second integer as a power to the first

My instructor assigns Design and Implement a C++ program to do math. Accept two integers from the user and Output their sum, difference, product, quotient, remainder and division result; raise the second integer as a power to the first integer.
Outputs should be formatted and aligned in a tubular form. I've managed to complete everything from this point on. Im currently stuck, I don't understand how I should format the code on raising the power to the first


#include<iostream>
#include<iomanip>
using namespace std;


int main ( )
{
int num1, num2;
cout << "enter two integers:";
cin >> num1, num2;

double sum, difference;
double product, quotient, remainder;

sum = num1 + num2;
difference = num1 - num2;
product = num1 * num2;
quotient = num1 / num2;


sum = num1 + num2;
cout << num1 <<"\t+\t" << num2;
cout << "\t=\t" <<sum << endl;

difference = num1 - num2;
cout << num1 <<"\t-\t" << num2;
cout << "\t=\t" <<difference <<endl;

product = num1 * num2;
cout << num1 <<"\t*\t" << num2;
cout << "\t=\t" <<product <<endl;

quotient = num1 / num2;
cout << num1 <<"\t/\t" << num2;
cout << "\t=\t" <<quotient <<endl;

remainder = num1 % num2;
cout << num1 <<"\t%\t" << num2;
cout << "\t=\t" <<remainder <<endl;














return 0;

} // end of main function




Hi,

please Use code tags for all of your code to make it readable - http://www.cplusplus.com/articles/jEywvCM9/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <cmath> // include this for the function

using namespace std;

int main() {

	int x = 2;
	int y = 5;

	int sum = pow(x, y); // This is 2 to the power of 5 - 2^5
	cout << "2^5 = " << sum;
	//http://www.cplusplus.com/reference/cmath/pow/
	return 0;
}
Last edited on
I apologize for not using code tags. But thank you!
Topic archived. No new replies allowed.