Question
may I get help C++
pls
2) (6 pts) Reference parameters: Write a function that utilies reference parameters It should calil a function you write that returns the orlginal value of n, and also "returns the value of the number n raised to powers: nm n, by overwriting the corresponding reference parameters. DO NOT use any math fu ibraries, Just muitiply. DO NOT DO ANY VO IN THE FUNCTION, just process thelnputs and update the reference double pouore (double n,, doubles ng, doublet oubo, daubloe edad· double.esrth) erwriting the corresponding reference parameters, DO NOT use any math function's) from any n raised to powers: m, ms, m. and g reference parameters. DO NOT use any math functionls) from any C ibraries, Just multiply. DO NOT DO ANY VO outputs Also write a sain() program that loops, asking the user to enter a number or O to quit. Then it callsthe powsrs t) function, and prints out the values of all on one line, such as "Powers of 2 are 4 8 Also write a sain() program that loops, asking the user to enter a number or O to quit. Then it calls the 1632", It shoulkd repeat this process until the user enters a o, and then should print "Goodbye" and exit.
Explanation / Answer
#include <iostream>
using namespace std;
double powers(double n, double &sq, double &cube, double &quad, double &fifth)
{
sq = n * n;
cube = n * n * n;
quad = n * n * n * n;
fifth = n * n * n * n * n;
return n;
}
int main()
{
double n, sq, cube, quad, fifth;
do
{
cout<<"Enter the number or 0 to quit: ";
cin>>n;
if(n == 0)
break;
powers(n, sq, cube, quad, fifth);
cout<<"Powers of "<<n<<" are "<<sq<<" "<<cube<<" "<<quad<<" "<<fifth<<endl;
}while(n != 0);
}