My own program

B

BIGeasy

I'm trying to create an program that:
1. Prompts the user to enter three numbers and show the largest of the
three.
2.Takes the largest number and raises it to the smallest number.
3.Takes that result and raises it to the middle number.

I'm have step1 and 2 down, but I'm having trouble with the third
function which is step3. Here is the code I have for the function so
far:

//Raises the result of powerhouse1 to the middle
double powerhouse2(double mth, double nth, double oth)
{
double lowrise = pow(mth, oth);
double higherrise = pow(lowrise, nth);

return higherrise;
}
 
V

Victor Bazarov

BIGeasy said:
I'm trying to create an program that:
1. Prompts the user to enter three numbers and show the largest of the
three.
2.Takes the largest number and raises it to the smallest number.
3.Takes that result and raises it to the middle number.

I'm have step1 and 2 down, but I'm having trouble with the third
function which is step3. Here is the code I have for the function so
far:

//Raises the result of powerhouse1 to the middle
double powerhouse2(double mth, double nth, double oth)
{
double lowrise = pow(mth, oth);

So, 'mth' is the largest and 'oth' is the smallest, I take it? So, nth
is the middle, right?
double higherrise = pow(lowrise, nth);

return higherrise;
}

Given the assumptions I divined, the function is OK. You could, of
course, write a single return statement:

double powerhouse2(double mth, double nth, double oth)
{
return pow(pow(mth, oth), nth);
}

but what the hay...

V
 
H

Howard

BIGeasy said:
I'm trying to create an program that:
1. Prompts the user to enter three numbers and show the largest of the
three.
2.Takes the largest number and raises it to the smallest number.
3.Takes that result and raises it to the middle number.

I'm have step1 and 2 down, but I'm having trouble with the third
function which is step3. Here is the code I have for the function so
far:

//Raises the result of powerhouse1 to the middle
double powerhouse2(double mth, double nth, double oth)
{
double lowrise = pow(mth, oth); // <-- step 2
double higherrise = pow(lowrise, nth); // <-- step 3

return higherrise;
}

What problem are you having? This looks to me like it would work.
Although, it is doing both step 2 and step 3, wherease you've stated you're
doing step 2 ok, but having trouble with step 3. I don't know what
powerhouse1 is doing, but powerhouse2 is raising mth to the power oth, then
raising the result of that to the power nth, which is what steps 2 and 3
(combined) should do, correct?

-Howard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top