Write a for loop that will take a base and an exponent and w

Write a for loop that will take a base and an exponent and will write the result of base raised to the power of exponent. The input/output should be the following

Solution

int base,exponent;
cin>>base;
cin>>exponent;
int val=1;
for(int i=1;i<=exponent;i++)
{
val=val*base;
}
cout<<val;

 Write a for loop that will take a base and an exponent and will write the result of base raised to the power of exponent. The input/output should be the follow

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site