|
From: Scott <fre...@ve...> - 2005-10-31 01:08:26
|
Okay another simple C question....
I would like to make a quick HP calculator in C.
(just mucking around with DevC)
I would like to ask for user input, and then show the total...
Something like:
#include <stdio.h>
main()
{
float Weight, Speed, Time;
printf("Enter the weight : ");
scanf("%f",&Weight);
printf("Enter the Speed : ");
scanf("%f",&Speed);
Time =3D Weight*Speed;
printf("\n Time is =A3%5.2f",total);
}
The formula is: hp =3D weight * (speed / 234)3
How does one used cubed? is it something like 234*x*x ?
Anyone shed some simple light...
The example above is just something i imagine it will look like...
Cheers,
Scott.
|
|
From: Scott <fre...@ve...> - 2005-10-31 02:51:04
|
Okay thanks to everyone, i'm looking into POW
and the maths.h.
This code example gives me Power as 1.38
And i wanted it to equal 330 HP....
Iv'e tried a few variations, but still no luck!
#include <stdio.h>
#include <math.h>
#define time 5.825
/*The formula is: hp =3D weight / (ET / 5.825)3*/
main()
{
float Weight, ET, Power;
printf("Enter the weight in pounds : ");
scanf("%f",&Weight);
printf("Enter the ET in Seconds : ");
scanf("%f",&ET);
Power =3D Weight/ET/pow(time,3);
printf("Power EST is %3.2f",Power);
}
I'm sure it's just a matter of the POW being
in the wrong place...?
Cheers,
Scott. |
|
From: Scott <fre...@ve...> - 2005-10-31 02:56:57
|
Should of mentioned
I used 3500 pounds (weight)
12.8 seconds (ET)
Should give me 330 (Power)
However power is giving me 1.38
Power =3D Weight/ET/pow(time,3);
The formula is: hp =3D weight / (ET / 5.825)3*
So what stupid thing am i doing wrong?
Cheers
Scott.
#include <stdio.h>
#include <math.h>
#define time 5.825
/*The formula is: hp =3D weight / (ET / 5.825)3*/
main()
{
float Weight, ET, Power;
printf("Enter the weight in pounds : ");
scanf("%f",&Weight);
printf("Enter the ET in Seconds : ");
scanf("%f",&ET);
Power =3D Weight/ET/pow(time,3);
printf("Power EST is %3.2f",Power);
}
|
|
From: Josh M. <mrl...@gm...> - 2005-10-31 03:25:27
|
It looks to me like you want this:
Power =3D Weight / pow((ET / 5.825), 3);
Remember, the first parameter of pow() is the number you want raised
to a certain exponent.
On 10/30/05, Scott <fre...@ve...> wrote:
>
> Should of mentioned
>
> I used 3500 pounds (weight)
> 12.8 seconds (ET)
>
> Should give me 330 (Power)
> However power is giving me 1.38
>
> Power =3D Weight/ET/pow(time,3);
> The formula is: hp =3D weight / (ET / 5.825)3*
>
> So what stupid thing am i doing wrong?
>
> Cheers
> Scott.
>
>
>
> #include <stdio.h>
> #include <math.h>
> #define time 5.825
> /*The formula is: hp =3D weight / (ET / 5.825)3*/
> main()
> {
> float Weight, ET, Power;
> printf("Enter the weight in pounds : ");
> scanf("%f",&Weight);
> printf("Enter the ET in Seconds : ");
> scanf("%f",&ET);
> Power =3D Weight/ET/pow(time,3);
> printf("Power EST is %3.2f",Power);
> }
>
>
>
>
--
Cheers,
Josh
|
|
From: Scott <fre...@ve...> - 2005-10-31 03:35:42
|
>It looks to me like you want this: >Power = Weight / pow((ET / 5.825), 3); Yes, thanks to all of you that did the trick..... Now i'll just have to understand why that works... I'm glad i'm not sending people to the Moon..:) Thanks to everyone, for their prompt and helpful replies, it really makes trying to learn this crap, far more tolerable, with the excellent and quick help from you guys..... I do appreciate it.. Thanks again.... Cheers, Scott. |
|
From: Josh M. <mrl...@gm...> - 2005-10-31 04:13:45
|
pow( [base number], [exponent] ) pow( 2, 3 ) =3D=3D 8 =3D=3D 2^3 (where ^ represents exponent, not exclusive= or) pow( 3, 2 ) =3D=3D 9 =3D=3D 3^2 Does that help? On 10/30/05, Scott <fre...@ve...> wrote: > >It looks to me like you want this: > > >Power =3D Weight / pow((ET / 5.825), 3); > > Yes, thanks to all of you that did the trick..... > Now i'll just have to understand why that works... > > I'm glad i'm not sending people to the Moon..:) > > Thanks to everyone, for their prompt and helpful > replies, it really makes trying to learn this crap, > far more tolerable, with the excellent and quick help > from you guys..... I do appreciate it.. > > Thanks again.... > > Cheers, > Scott. > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the JBoss Inc. > Get Certified Today * Register for a JBoss Training Course > Free Certification Exam for All Training Attendees Through End of 2005 > Visit http://www.jboss.com/services/certification for more information > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > -- Cheers, Josh |
|
From: Per W. <pw...@ia...> - 2005-10-31 01:17:56
|
You either just write x*x*x or you #include <math.h>
and then write pow(x,3).
/Per W
On Mon, 31 Oct 2005, Scott wrote:
> Okay another simple C question....
>
> I would like to make a quick HP calculator in C.
> (just mucking around with DevC)
> I would like to ask for user input, and then show the total...
>
> Something like:
>
> #include <stdio.h>
> main()
> {
> float Weight, Speed, Time;
> printf("Enter the weight : ");
> scanf("%f",&Weight);
> printf("Enter the Speed : ");
> scanf("%f",&Speed);
> Time =3D Weight*Speed;
> printf("\n Time is =A3%5.2f",total);
> }
>
> The formula is: hp =3D weight * (speed / 234)3
>
> How does one used cubed? is it something like 234*x*x ?
> Anyone shed some simple light...
>
> The example above is just something i imagine it will look like...
>
> Cheers,
> Scott.
>
|