Check whether the triangle is valid or not if angles are given Last Updated : 04 Jun, 2022 Comments Improve Suggest changes Like Article Like Report 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 three angles is equal to 180 degrees. Below is the implementation of the above approach: C++ // C++ implementation of the approach #include <bits/stdc++.h> using namespace std; // Function to check if sum of the // three angles is 180 or not bool Valid(int a, int b, int c) { // Check condition if (a + b + c == 180 && a != 0 && b != 0 && c != 0) return true; else return false; } // Driver code int main() { int a = 60, b = 40, c = 80; if (Valid(a, b, c)) cout << "Valid"; else cout << "Invalid"; } Java // Java program to check // validity of any triangle class GFG { // Function to check if sum of the // three angles is 180 or not public static int Valid(int a, int b, int c) { // check condition if (a + b + c == 180 && a != 0 && b != 0 && c != 0) return 1; else return 0; } // Driver Code public static void main(String args[]) { int a = 60, b = 40, c = 80; // function calling and print output if ((Valid(a, b, c)) == 1) System.out.print("Valid"); else System.out.print("Invalid"); } } // This code is contributed // by Apurva Sharma Python3 # Python3 implementation of the approach # Function to check if sum of the # three angles is 180 or not def Valid(a, b, c): # Check condition if ((a + b + c == 180) and a != 0 and b != 0 and c != 0): return True else: return False # Driver code if __name__ == "__main__": a = 60 b = 40 c = 80 if (Valid(a, b, c)): print("Valid") else: print("Invalid") # This code is contributed by # sanjeev2552 C# // C# program to check // validity of any triangle using System; class GFG { // Function to check if sum of the // three angles is 180 or not public static int Valid(int a, int b, int c) { // check condition if (a + b + c == 180 && a != 0 && b != 0 && c != 0) return 1; else return 0; } // Driver Code public static void Main() { int a = 60, b = 40, c = 80; // function calling and print output if ((Valid(a, b, c)) == 1) Console.WriteLine("Valid"); else Console.WriteLine("Invalid"); } } // This code is contributed // by anuj_6 JavaScript // javascript program to check // validity of any triangle // Function to check if sum of the // three angles is 180 or not function Valid(a, b, c) { // check condition if (a + b + c == 180 && a != 0 && b != 0 && c != 0) return 1; else return 0; } // Driver Code var a = 60, b = 40, c = 80; // function calling and print output if ((Valid(a, b, c)) == 1){ document.write("Valid"); } else{ document.write("Invalid"); } // This code is contributed by bunnyram19. Output: Valid Time Complexity: O(1) Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article Check whether the triangle is valid or not if angles are given apurva_sharma244 Follow Improve Article Tags : Mathematical Geometric DSA triangle school-programming +1 More Practice Tags : GeometricMathematical Similar Reads Check whether triangle is valid or not if sides are given Given three sides, check whether triangle is valid or not. Examples: Input : a = 7, b = 10, c = 5 Output : ValidWe can draw a triangle with the given three edge lengths.Input : a = 1, b = 10, c = 12 Output : InvalidWe can not draw a triangle with the given three edge lengths.Approach: A triangle is 4 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 a given point lies inside a triangle or not Given three corner points of a triangle, and one more point P. Write a function to check whether P lies within the triangle or not. Example: Input: A = (0, 0), B = (10, 30), C = (20, 0), P(10, 15)Output: InsideExplanation: B(10,30) / \ / \ / \ / P \ P' / \ A(0,0) ----------- C(20,0) Input: A = (0, 0 15+ min read Check whether right angled triangle is valid or not for large sides Given three integers a, b and c as triplets. Check if it is possible to make right angled triangle or not. Print Yes if possible, else No. 10-18 <= a, b, c <= 1018 Examples: Input: 3 4 5 Output: Yes Explanation: Since 3*3 + 4*4 = 5*5 Hence print "Yes" Input: 8 5 13 Since 8 + 5 < 13 which vi 8 min read Check if a right-angled triangle can be formed by the given side lengths Given two positive integers A and B representing the sides of a triangle, the task is to check if the given two sides of the triangle are sides of a valid right-angled triangle or not. If found to be true, print "YES". Otherwise, print "No". Examples: Input: A = 3, B = 4Output: Yes Explanation: A ri 8 min read Check if an N-sided Polygon is possible from N given angles Given an array arr[] of N elements, where each element represents an angle(in degrees) of a polygon, the task is to check whether it is possible to make an N-sided polygon with all the given angles or not. If it is possible then print Yes else print No. Examples: Input: N = 3, arr[] = {60, 60, 60}Ou 4 min read Program To Check whether a Triangle is Equilateral, Isosceles or Scalene Given three integers as X, Y, and Z representing the three sides of a triangle, the task is to check whether the triangle formed by the given sides is equilateral, isosceles, or scalene. Equilateral Triangle: A triangle is said to be equilateral triangle if all the sides are equal. If X, Y, Z are th 5 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 Check if a right-angled triangle can be formed by the given coordinates Given three Cartesian coordinates, the task is to check if a right-angled triangle can be formed by the given coordinates. If it is possible to create a right-angled triangle, print Yes. Otherwise, print No. Examples: Input: X1=0, Y1=5, X2=19, Y2=5, X3=0, Y3=0 Output: Yes Explanation: Length of side 5 min read Check if a right-angled triangle can be formed by moving any one of the coordinates Given three coordinates of a triangle (x1, y1), (x2, y2), (x3, y3). The task is to find out if the triangle can be transformed to a right-angled triangle by moving only one point exactly by the distance 1. If it is possible to make the triangle right-angled, then print "POSSIBLE", else print "NOT PO 12 min read Like