Question
The following partial specification of the pow subroutine is given: / The pow subroutine calculates powers of natural bases and exponents . Arguments : base
The following partial specification of the pow subroutine is given:
/ The pow subroutine calculates powers of natural bases and exponents . Arguments : base the exponential base exp the exponent Return value: base raised to the power of exp. / int pow(int base, int exp) {
int total = 1;// . . . return total ;
}
a)Complete the specification of the pow subroutine and have it checked by the lab course assistants. You should only use looping constructs and simple arithmetic operations to compute the total.
b)Write a program called power which contains an implementation of your pow subroutine. The main routine should ask the user for a positive base and exponent. The program should then calculate the resulting power using the pow subroutine and print the return value.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started