In this article we will check whether the given triangle is valid or not using angles. First of all we will take input angles from the user and check whether it is valid triangle or not. As we know that if the some of all three angles is equal to 180 then it is valid otherwise not. So we will check the same in following program:-
In following program we have taken 3 variables i.e a1, a2 and a3. We will take input from the user and using if else condition we will check whether the sum of all three angles are equal to 180.
#include<stdio.h>
void main()
{
int a1,a2,a3;
printf("Enter the value of 3 angle");
scanf("%d%d%d",&a1,&a2,&a3);
if((a1+a2+a3)==180)
{
printf("Triangle is Valid");
}
else
{
printf("Triangle is NOT Valid");
}
}
Here is the output of above program.
Figure 1