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: 645991 • 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, doubles cube, doubles quad, doubles 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.

Explanation / Answer

#include <iostream> using namespace std; int main() { int exp; float base, power = 1; cout << "Enter base and exponent respectively: "; cin >> base >> exp; while (exp != 0) { power *= base; --exp; } cout << "Result = " << power; return 0; } -

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