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