Question: 6. (20 points) Write a C++ program called power.cpp to compute 2 for a nonnegative integer n. In this program, you have to develop a

6. (20 points) Write a C++ program called power.cpp to compute 2" for a nonnegative integer n. In this program, you have to develop a recursive function to calculate it. And also, you can't use a library in the program. For the problem, you can assume that the user always enter a correct integer number which is greater than or equal to zero. [Hint: Use the formula: 2" = 2*2"-1 for the recursive function.] Here are some sample test cases: Page 2 of 4 Test case 1 Enter a number: 0 Result: 1 Test case 2 Enter a number: 4 Result: 16 Test case 3 - We read your program and check if it uses a recursive function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
