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

2) (6 pts) Reference parameters: Write a function that utilizes reference parame

ID: 645985 • Letter: 2

Question

2) (6 pts) Reference parameters: Write a function that utilizes reference parameters. It should call a function you write, double powers (double n, double& sq, double& cube, double& quad, double& fifth) that returns the original value of n, and also ''returns'' the value of the number n raised to powers: n^2, n^3, n^4, and n^5, by overwriting the corresponding reference parameters. DO NOT use any math function(s) from any C libraries, just multiply. DO NOT DO ANY I/O IN THE FUNCTION, just process the inputs and update the reference ''outputs''. Also write a main () program that loops, asking the user to enter a number or 0 to quit. Then it calls the powers function, and prints out the values of all on one line, such as ''Powers of 2 are 4 8 16 32''. It should repeat this process until the user enters a 0, and then should print ''Goodbye'' and exit. Grading Criteria (1 point each): Uses cin/cout correct function definition & usage prompts user for input, reads it in quits when 0 entered, prints ''Goodbye'' Prints user input and correct n^2, n^3, n^4, and n^5 Prints user comments & meaningful variable names

Explanation / Answer

#include using namespace std; int squarerootfinder(int number, int divisor){ if(divisor == 1){ return 1; } else{ if((number / (divisor * divisor))% 1 != 0){ divisor = squarerootfinder(number, divisor - 1); } if((number/ (divisor * divisor)) % 1 == 0 ){ return divisor; } } } int main(){ int number; cout > number; int divisor = number; int squareroot; squareroot = squarerootfinder(number, divisor); cout
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