Check if a triangle of positive area is possible with the given angles Last Updated : 29 Jun, 2022 Comments Improve Suggest changes Like Article Like Report Given three angles. The task is to check if it is possible to have a triangle of positive area with these angles. If it is possible print "YES" else print "NO".Examples: Input : ang1 = 50, ang2 = 60, ang3 = 70 Output : YES Input : ang1 = 50, ang2 = 65, ang3 = 80 Output : NO Approach: We can form a valid triangle if the below conditions satisfies: The sum of the three given angles equals to 180.The sum of any two angles is greater than equal to the third one.None of the given angles is zero. Below is the implementation of the above approach: C++ // C++ program to check if a triangle // of positive area is possible with // the given angles #include <bits/stdc++.h> using namespace std; string isTriangleExists(int a, int b, int c) { // Checking if the sum of three // angles is 180 and none of // the angles is zero if(a != 0 && b != 0 && c != 0 && (a + b + c)== 180) // Checking if sum of any two angles // is greater than equal to the third one if((a + b)>= c || (b + c)>= a || (a + c)>= b) return "YES"; else return "NO"; else return "NO"; } // Driver Code int main() { int a=50, b=60, c = 70; cout << isTriangleExists(a, b, c) << endl; return 0; } // This code is contributed by mits Java // Java program to check if a triangle // of positive area is possible with // the given angles class GFG { static String isTriangleExists(int a, int b, int c) { // Checking if the sum of three // angles is 180 and none of // the angles is zero if(a != 0 && b != 0 && c != 0 && (a + b + c)== 180) // Checking if sum of any two angles // is greater than equal to the third one if((a + b)>= c || (b + c)>= a || (a + c)>= b) return "YES"; else return "NO"; else return "NO"; } // Driver Code public static void main(String[] args) { int a=50, b=60, c = 70; System.out.println(isTriangleExists(a, b, c)); } } // This code is contributed by mits Python # Python program to check if a triangle # of positive area is possible with # the given angles def isTriangleExists(a, b, c): # Checking if the sum of three # angles is 180 and none of # the angles is zero if(a != 0 and b != 0 and c != 0 and (a + b + c)== 180): # Checking if sum of any two angles # is greater than equal to the third one if((a + b)>= c or (b + c)>= a or (a + c)>= b): return "YES" else: return "NO" else: return "NO" # Driver Code a, b, c = 50, 60, 70 print(isTriangleExists(50, 60, 70)) C# // C# program to check if a triangle // of positive area is possible with // the given angles class GFG { static string isTriangleExists(int a, int b, int c) { // Checking if the sum of three // angles is 180 and none of // the angles is zero if(a != 0 && b != 0 && c != 0 && (a + b + c) == 180) // Checking if sum of any two // angles is greater than equal // to the third one if((a + b) >= c || (b + c) >= a || (a + c) >= b) return "YES"; else return "NO"; else return "NO"; } // Driver Code static void Main() { int a = 50, b = 60, c = 70; System.Console.WriteLine(isTriangleExists(a, b, c)); } } // This code is contributed by mits PHP <?php // PHP program to check if a triangle // of positive area is possible with // the given angles function isTriangleExists($a, $b, $c) { // Checking if the sum of three // angles is 180 and none of // the angles is zero if($a != 0 && $b != 0 && $c != 0 && ($a + $b + $c) == 180) // Checking if sum of any two // angles is greater than equal // to the third one if(($a + $b)>= $c || ($b + $c)>= $a || ($a + $c)>= $b) return "YES"; else return "NO"; else return "NO"; } // Driver Code $a = 50; $b = 60; $c = 70; echo isTriangleExists($a, $b, $c); // This code is contributed by mits ?> JavaScript <script> // javascript program to check if a triangle // of positive area is possible with // the given angles function isTriangleExists(a , b , c) { // Checking if the sum of three // angles is 180 and none of // the angles is zero if (a != 0 && b != 0 && c != 0 && (a + b + c) == 180) // Checking if sum of any two angles // is greater than equal to the third one if ((a + b) >= c || (b + c) >= a || (a + c) >= b) return "YES"; else return "NO"; else return "NO"; } // Driver Code var a = 50, b = 60, c = 70; document.write(isTriangleExists(a, b, c)); // This code is contributed by Rajput-Ji </script> Output: YES Time complexity: O(1) Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article Check whether triangle is valid or not if three points are given I indrajit1 Follow Improve Article Tags : DSA Similar Reads Check whether the triangle is valid or not if angles are given Given three integers A, B and C which are the three angles of a possible triangle in degrees, the task is to check whether the triangle is valid or not.Examples: Input: A = 60, B = 40, C = 80 Output: ValidInput: A = 55, B = 45, C = 60 Output: Invalid Approach: A triangle is valid if the sum of the t 3 min read Area of the circumcircle of any triangles with sides given Given a triangle with known sides a, b and c; the task is to find the area of its circumcircle.Examples: Input: a = 2, b = 2, c = 3Output: 7.17714 Input: a = 4, b = 5, c = 3Output: 19.625 Approach: For a triangle with side lengths a, b, and c, Radius of the circumcircle: R = \frac{abc}{\sqrt{\left ( 6 min read Check whether triangle is valid or not if three points are given Given coordinates of three points in a plane P1, P2 and P3, the task is to check if the three points form a triangle or notExamples: Input: P1 = (1, 5), P2 = (2, 5), P3 = (4, 6) Output: YesInput: P1 = (1, 1), P2 = (1, 4), P3 = (1, 5) Output: No Approach: The key observation in the problem is three p 9 min read Check whether triangle is valid or not if three points are given Given coordinates of three points in a plane P1, P2 and P3, the task is to check if the three points form a triangle or notExamples: Input: P1 = (1, 5), P2 = (2, 5), P3 = (4, 6) Output: YesInput: P1 = (1, 1), P2 = (1, 4), P3 = (1, 5) Output: No Approach: The key observation in the problem is three p 9 min read Check whether triangle is valid or not if three points are given Given coordinates of three points in a plane P1, P2 and P3, the task is to check if the three points form a triangle or notExamples: Input: P1 = (1, 5), P2 = (2, 5), P3 = (4, 6) Output: YesInput: P1 = (1, 1), P2 = (1, 4), P3 = (1, 5) Output: No Approach: The key observation in the problem is three p 9 min read Check if it is possible to create a polygon with a given angle Given an angle a where, 1\le a< 180 . The task is to check whether it is possible to make a regular polygon with all of its interior angle equal to a . If possible then print "YES", otherwise print "NO" (without quotes). Examples: Input: angle = 90 Output: YES Polygons with sides 4 is possible wi 4 min read Like