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.
Input format :
Two integers x and n (separated by space)Output Format :
x^n (i.e. x raise to the power n)Sample Input 1 :
3 4
Sample Output 1 :
81
Sample Input 2 :
2 5
Sample Output 2 :
32
C++ Code :
#include<iostream>
using namespace std;
int main()
{
int x, n, i, pow=1;
cin>>x>>n;
for(i=n;i>0;i--)
{
pow=pow*x;
}
cout << pow;
}
some related posts :-
1.sum of even or odd digits in a given numbers in c++
2. c++ program to find roots of quadratic equation || roots of quadratic equation in c/c++.
2. c++ program to find roots of quadratic equation || roots of quadratic equation in c/c++.
3. print triangle number pattern.
1
11
111
1111
4. check whether the character is an uppercase or lowercase.
5. find the average marks of three subject in c++
1
11
111
1111
4. check whether the character is an uppercase or lowercase.
5. find the average marks of three subject in c++
0 comments:
Post a Comment