C Program to Check Whether a Triangle is Valid or Not Given Angles of Triangle

In this C program, we will learn about how to check whether a triangle is valid or not from given angles of triangle. A triangle is a valid triangle, If and only If the sum of all internal angles is equal to 180. This is known as angle sum property of triangle.

We will use this triangle property to check whether three given angles can form a valid triangle.

Required Knowledge


C program to check whether a triangle is valid, given angles of triangle

#include <stdio.h>  
  
int main() {  
    int angle1, angle2, angle3;  
 
    printf("Enter Three Angles of a Triangle\n");  
    scanf("%d %d %d", &angle1, &angle2, &angle3);     
  
    if( angle1 + angle2 + angle3 == 180) {  
        printf("It is a Valid Triangle\n");  
    } else {  
        printf("It is an invalid Triangle");  
    }  
  
    return 0;  
}
Output
Enter Three Angles of a Triangle
30 60 90
It is a Valid Triangle
Enter Three Angles of a Triangle
60 70 80
It is an invalid Triangle

Related Topics
C Program to Check Whether a Triangle is Valid or Not given Sides of Triangle
C Program to Check Whether a Triangle is Equilateral, Isosceles or Scalene Triangle
C Program to Calculate Area of a Right Angled Triangle
C Program to Calculate Area of Any Triangle using Heron's Formula
C Program to Find Third Angle of a Triangle
C Program to Print Floyd's Triangle
C Program to Print Triangle and Pyramid patterns of Star(*) Character Using Loop
C Program to Print Pascal Triangle till N Rows
C Program to Calculate Area and Perimeter of an Equilateral Triangle
List of all C programs