In this program, we use C++ Math.pow()
function to calculate the power of the given base.
C++ Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include<iostream> #include<math.h> //for pow() function using namespace std; int main() { system ("CLS"); //to clear the screen int base,exponent,result; cout<<"Enter value of base: "; cin>>base; cout<<"Enter value of exponent: "; cin>>exponent; result=pow(base,exponent); cout<<"Result="<<result; return 0; } |