C++ Program

Object:-Write a Program to raise any number x to a positive power n

#include
#include
#include  //for pow() function

void main()
{
    clrscr();
    int x,n,res;
    cout<<“Enter value of x and n:”;
    cin>>x>>n;
    res=pow(x,n);
    cout<<“Result=”<< res;
    getch();
}

Output

Enter value of x and n:5  2
Result=25
 

Explanation

	Pow accepts two parameters: base and exponent. 







You may also like: