Program: 75
Write a program to check whether a triangle is valid or not, when the three angles of the triangle are entered through the keyboard. A triangle is valid if the sum of all the three angles is equal to 180 degrees.
#include<stdio.h> #include<conio.h> int main() { int a, b, c, sum; printf("Enter three angles of a triangle: "); scanf("%d %d %d", &a, &b, &c ); sum = a+b+c; if (sum == 180) printf("Triangle is valid"); else printf("Triangle is not valid"); return 0; }
Output:
Enter three angles of a triangle: 60 60 40
Triangle is not valid
Leave a Comment