Hrm!!!
^ is the XOR bitwise operator in C and C++.
Do not even _think_ about using it as power operator. The code will
compile, but the result is _very_ wrong.
/Per W
On Mon, 31 Oct 2005, Jarren Long wrote:
> Scott:
> You could also just do this:
> hp =3D weight * ((speed / 234)^3)
> Using the ^ is the same as doing pow((speed/234),3);
> Cheers,
> Jarren
>
> 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.
> >
>
|