I am asked to create a function to check if it forms a right angled triangle. My code only works if my input are integers, but once I start putting in non-integer values, it fails, eg, 1,1 and sqrt(2). How do I fix this? Following is my code.
right.angled.triangles=function(a,b,c){
x=sort(c(a,b,c))
if(any(x<0)){
"Invalid lengths"
}else {
if(x[1]^2+x[2]^2==x[3]^2){
"Right angled triangle"
}else{
"Not a right angled triangle"
}
}
}