Find power of a number
Write a program to find x to the power n (i.e. x^n). Take x and n from the user. You need to print the answer.
Note : For this question, you can assume that 0 raised to the power of 0 is 1
#include<iostream>
using namespace std;
int main() {
// Write your code here
int a,b,tempo,mul;
cin>>a>>b;
tempo=a;
mul=0;
for (int i=1;i<b;i++){
a=a*(tempo);
}
if (b==0){
a=1;
}
cout<<a;
}
Comments
Post a Comment