Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

/* This program cacluates the result of a number raised to an integer power. */

ID: 3641363 • Letter: #

Question

/* This program cacluates the result of a number raised to an integer power. */
#include <iostream>
using namespace std;
//Function declaration
double my_pow(double, int);
int main()
{
double base;
int power;
//Continue asking for input until user enters 0 as base.
do
{
cout << " Enter the base of the number (0 to exit): ";
cin >> base;
if (base == 0)
break;
cout << "Enter the power (integer): ";
cin >> power;
cout << "The result is: " << my_pow(base, power) << endl;
}
while (true);
system("pause");
return 0;
}
//Function definition
(Add your code here)


                                                           Sample input/output:
Enter the base of the number (0 to exit): 3
Enter the power (integer): 3
The result is: 27


Enter the base of the number (0 to exit): 4
Enter the power (integer): 0
The result is: 1


Enter the base of the number (0 to exit): -5
Enter the power (integer): 3
The result is: -125


Enter the base of the number (0 to exit): 2.34
Enter the power (integer): 2
The result is: 5.4756


Enter the base of the number (0 to exit): 2
Enter the power (integer): -3
The result is: 0.125

Explanation / Answer

Pease rate...

#include <iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;
//Function declaration
double my_pow(double, int);
int main()
{
double base;
int power;
//Continue asking for input until user enters 0 as base.
do
{
cout << " Enter the base of the number (0 to exit): ";
cin >> base;
if (base == 0)
break;
cout << "Enter the power (integer): ";
cin >> power;
cout << "The result is: " << my_pow(base, power) << endl;
}
while (true);
system("pause");
return 0;
}
//Function definition
double my_pow(double b,int p)
{
    int i;
    double m=1.0;
    for(i=1;i<=p;i++)
    {
        m=m*b;
    }
    return m;
}