IntPower Program
Description
This program inputs two integers: base and exponent, and then calculates baseexponent using recursion technique.Associated Concepts:
Recursion
Algorithm:
main method:
Declare variables
Input two integers: base and exponent from the keyboard
Call the recursive method myPow() with base and exponent as the arguments
Print the result
myPow method definition:
Declare variables
Input two integers: base and exponent from the keyboard
Call the recursive method myPow() with base and exponent as the arguments
Print the result
myPow method definition:
If the method is call with the base case: exponent is 0,
it returns the result.
Otherwise, the method returns base * myPow(base, exponent - 1).
Otherwise, the method returns base * myPow(base, exponent - 1).