c++

Please can someone help me solve this equation.
square root of a^2+b^2 = c.
thanks.
Yes. One solution is a=1, b=-1 and c=2.
I like a=3, b=4, c=5 because it is a whole number solutions to c = sqrt(a2 + b2).

@Moschops: you missed the "square root of" in that. c != 2; c = sqrt(2).
I've always appreciated a=3, b=4, c=5 for that same reason.
PanGalactic wrote:
@Moschops: you missed the "square root of" in that. c != 2; c = sqrt(2).

But that's what the OP asked for, so Moschops is indeed correct.
There are plenty of whole number solutions to this equation. I like 3, 4, 5 because the numbers are in arithmetic progression. :-)
Other examples of Pythag triples:
5, 12, 13
6, 8, 10
500, 1200, 1300
etc.
Last edited on
 
double c = sqrt(pow(a, 2), pow(b, 2));


Assuming both 'a' and 'b' are doubles.

EDIT: Read this reference: http://www.cplusplus.com/reference/clibrary/cmath/
Last edited on
Topic archived. No new replies allowed.