Valid Triangles
Practice this coding question on Coding Gurukul.
Problem statement
A workshop creates triangular signs from designs submitted by students. Each design records three interior angles in degrees. Before any material is cut, a validation program must decide whether these angles can belong to a triangle. The program checks the geometry of the design; it does not need to calculate side lengths or draw the sign. Your task For each design, read the three angles A, B and C. Print YES if all three are positive and their sum is exactly 180 degrees. Otherwise print NO. Important details An angle of zero cannot form a corner of a triangle. Having two equal angles is allowed, and a right angle is allowed. Check every design independently and preserve their input order. Worked example For angles 40, 60 and 80, the sum is 180 and each angle is positive, so the answer is YES. Angles 40, 60 and 70 total only 170, so that design receives NO.
Input format
The first line contains T. Each of the next T lines contains three integers A B C.
Output format
Print YES or NO on a separate line for each design.
Constraints
1 <= T <= 1000; 1 <= A, B, C <= 180.
Sample input
2 40 60 80 40 60 70
Sample output
YES NO
Sign in to run or submit a solution in C++, Java or Python.