HomeC++

C++ Program to Raise Any Number x to a Positive Power n

C++ Program to Raise Any Number x to a Positive Power n

Today we make a ┬áProgram To C++ Program to raise any number x to a positive power n.i’m using Dev c++.Now Try To Make it.

C++ Program to raise any number x to a positive power n

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int x,n,result=1;
cout << "Enter Number \"n\": ";
cin >> n;
cout << "\nEnter Power to Raise \"x\": ";
cin >> x;
if(x > 0)
{
for(int i=0;i<=x;i++)
result=x*n;
cout << "n Power x = " << result;
}
else
{
cout << "x must be a positive number";
}
getch();
return 0;
}

Output of ProgramC++ Program to Raise Any Number x to a Positive Power n

Comments (0)

Leave a Reply