# Valid Triangles | Codechef solution

Problem:-

Write a program to check whether a triangle is valid or not, when the three angles of the triangle are the inputs. A triangle is valid if the sum of all the three angles is equal to 180 degrees.

### Input

The first line contains an integer T, the total number of testcases. Then T lines follow, each line contains three angles AB and C, of the triangle separated by space.

### Output

For each test case, display 'YES' if the triangle is valid, and 'NO', if it is not, in a new line.

### Constraints

•  T  1000
• 1 ≤ A,B,C  180

### Example

Input

3
40 40 100
45 45 90
180 1 1
Output

YES
YES
NO


Code:-

#include <iostream>
using namespace std;

int main() {
int t,a,b,c;
cin>>t;
while(t--)
{
cin>>a>>b>>c;
int sum=a+b+c;
if(sum==180)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}

return 0;
}

Recommended Post:

Cracking the coding interview:-

Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

Key points:-

MCQs:-