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:Valid

Input: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"` `; ` `} ` |

*chevron_right*

*filter_none*

## 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 ` |

*chevron_right*

*filter_none*

## 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 ` |

*chevron_right*

*filter_none*

## 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 ` |

*chevron_right*

*filter_none*

**Output:**

Invalid

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Check whether Quadrilateral is valid or not if angles are given
- Check whether triangle is valid or not if sides are given
- Check whether triangle is valid or not if three points are given
- Check whether right angled triangle is valid or not for large sides
- Check if a triangle of positive area is possible with the given angles
- Find all angles of a given triangle
- Length of remaining two sides of a Triangle from a given side and its adjacent angles
- Check whether a given point lies inside a triangle or not
- Find all angles of a triangle in 3D
- Find other two sides and angles of a right angle triangle
- Check whether the given string is a valid identifier
- Check if an N-sided Polygon is possible from N given angles
- Check if the given Prufer sequence is valid or not
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Program to check if a date is valid or not
- Count of obtuse angles in a circle with 'k' equidistant points between 2 given points
- Program to find smallest difference of angles of two parts of a given circle
- Program To Check whether a Triangle is Equilateral, Isosceles or Scalene
- Check whether a given point lies inside a rectangle or not
- Check whether a given matrix is orthogonal or not

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.