Defining value of square root

Sep 15, 2012 at 2:49am
Hi, everyone. I'm new to programming and i've ran into a trouble.
right now, i'm trying to make a program that can decide whether a triangle is a right triangle or not. to do this i simply use Pythagoras theorem. the program actually runs fine without a trouble but this program can on;y check triangle having sides like 3,4,5 or 6,8,10. if i input two of the sides as 1 and 1 for example, i would need to input square root of 2 as the third sides if i want to m.My question is, is there any way possible for us to put square root of something as an input? Or make the program read a certain number as the square root of x(for example reading 1.4142 as square root of 2)?
Thank you.
And i'm sorry if my english is messy, it's not my mother language.
Sep 15, 2012 at 3:56am
My solution is to re-define the check-for-right-triangle function...

The new function calculates cosine of the bigest angle and determines if that cosine is approximately zero (less than a very small number, ex. 0.0001).

Use cos(C) = a^2+b^2-c^2 / 2ab
Return abs( cos(C) ) < abs ( smallCheckNbr )
Sep 15, 2012 at 4:14am
Topic archived. No new replies allowed.