Write a C++ program to find the value of one number raised to the power of another, where number is entered by programmer.

Program Code: 
#include<iostream> 
using namespace std; 
int main() 
int number, i;
int power;
int result=1;
cout<<"Enter the base number : ";
cin>>number;
cout<<endl;
cout<<"Enter the  exponent : ";
cin>>power;
cout<<endl;
for( i=1;i<=power;i++) 
{
result =result * number; 
}
cout<<"Result :"<<result;
return 0;
}
The program output is tested on www.jdoodle.com
Output:
Enter the base number : 5
Enter the exponent : 3
Result :125
Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: