Algorithm


 problem Link : https://www.codechef.com/problems/FLOW013 

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 Format

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 Format

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

Sample 1:

Input
 
Output
 
3 
40 40 100
45 45 90
180 1 1
YES
YES
NO

Code Examples

#1 Code Example with C Programming

Code - C Programming

#include<stdio.h>
int main()
{
    int i,n,a,b,c;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d %d %d",&a,&b,&c);
        if(a+b+c==180) printf("YES\n");
        else printf("NO\n");
    }
} 
Copy The Code & Try With Live Editor

Input

x
+
cmd
3
40 40 100
45 45 90
180 1 1

Output

x
+
cmd
YES
YES
NO
Advertisements

Demonstration


CodeChef solution CFLOW013  - Valid Triangles Codechef solution in C,C++

Previous
CodeChef solution FSQRT - Finding Square Roots CodeChef solution in C,C++
Next
CodeChef solution CHOPRT - Chef And Operators Codechef solution in C,C++