For this program, you should write and test a function that raises the first num
ID: 3685336 • Letter: F
Question
For this program, you should write and test a function that raises the first number to the power of the second number. The prototype should be as follows:
int toThePowerOf(int base, int exponent);
Your implementation of toThePowerOf SHOULD NOT use pow() and the function only needs to work with positive integers.
Write the main() in such a way that it asks the two numbers from the user and validates them to make sure they are positive integers. Then, it should call the function and display the output of calling the function as well as what calling pow() on the same two numbers gives you.
Explanation / Answer
#include void toThePowerOf(int a, int b); void main() { int a,b; clrscr(); printf(“Enter the base: “); scanf(“%d”,&a); printf(“Enter the power: “); scanf(“%d”,&b); while (b!=0) { power(a,b); getch(); } void power(int a, int b) { int c; c=a; for(i=1;iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.