Check whether the triangle is valid or not if angles are given Last Updated : 04 Jun, 2022 Summarize Comments Improve Suggest changes Share 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 A 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 Like