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

Write a C program to find y = x^ n using recursion, where x and n are non-zero p

ID: 3854407 • Letter: W

Question

Write a C program to find y = x^ n using recursion, where x and n are non-zero positive values less than 10. The user will input the value of x and n using scanf. The output can be printed using printf. Upload the C program to Blackboard. Convert the C program to LEGv8 assembly code. The scanf and printf functions does not have to be converted to assembly code. Do not use any predefined functions in your C code or assembly code. Write the assembly code in your homework document. Comment your C code and assembly code.

Explanation / Answer

The code required in the C programming language is as follows:

Raise.c

int raiseTo(int uu, unsigned int pp)
{
if (pp == 0)
return 1;
else if (pp%2 == 0)
return raiseTo(uu, pp/2)*raiseTo(uu, pp/2);
else
return uu*raiseTo(uu, pp/2)*raiseTo(uu, pp/2);
}

/* Program to test function raiseTo */
int main()
{
int uu = 2;
unsigned int pp = 3;

printf("%d", raiseTo(uu, pp));
return 0;
}

Please rate the answer if it helped.....Thankyou

Hope it helps.....

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote