+ 2
CHALLENGE: Third angle of triangle
You are given two angles (in degrees) of a triangle. Write a function to return the 3rd.
7 Réponses
+ 3
@Eligijus Silkartas
But you did not consider that the sum of these two angles may be greater than 180, then the triangle does not exist.
+ 2
double thirdAngle (double first , double second) {
if (first < 0 || second < 0) {
cout << "Invalid Inputs\n";
return -1;
}
else if ( first + second >= 180) {
cout << "It's not a Triangle !!\n";
return -1;
}
else {
return (180 - first - second);
}
}
+ 1
If this is euclidean geometry, then:
def angle3(angle1, angle2):
return 180 - angle1 - angle2
+ 1
@Ilia Fedorov
Yes that's true. There are more things to consider, like passed values can be negative or they can even be not numbers. But I am too lazy to write that code :D
0
is it on python??????????????
0
Here's mine!
https://code.sololearn.com/WMOWXCX37ksW/#html