Squaring

hey, im sure i've had this right before, but anyway.
i have a tiny pythag function that has a,b,h all as parameters and then inside the function i multiply each of those and return them by adding them all together.
When i compile i just get a warning saying that those statements hav no effect, and sure enough, they dont. Whats wrong!
Thanks.
posting your code would help...
1
2
3
4
5
6
7
double pythag(double a2, double b2, double h2)
{
    a2 * a2;
    b2 * b2;
    h2 * h2;
    return a2+b2+h2;
}
closed account (D80DSL3A)
Lines 3,4 and 5 are not assigning a value to anything.
If you want to multiply a2 by itself (for example) you can do it like so:
a2 = a2*a2;// calculate a2*a2 then assign this value to a2

Or you could use a shortcut method:
a2 *= a2;// multiply a2 by a2
Do this on all 3 lines and your function should work.
thanks im sorry for that trouble .
Topic archived. No new replies allowed.