AnkitWebLogic

9. Write a C Program to Input 3 angles of a triangle and check whether a triangle is valid or not. A triangle is valid if the sum of all the three angles equal to 180 degrees and no angle is equals to 0. 1

#include<stdio.h>
int main()
{
    int a,b,c,s;
    printf("Enter 3 angle values: ");
    scanf("%d%d%d",&a,&b,&c);
    s=a+b+c;
    if(s==180 && a!=0 && b!=0 && c!=0)
    {
        printf("Triangle is valid");
    }
    else
    {
        printf("Triangle is NOT valid");
    }
    return 0;
}
Output Run 1:
Enter 3 angle values: 30
90
30
Triangle is NOT valid

Output Run 2:
Enter 3 angles value90
45
45
Triangle is valid

Output Run 3:
Enter 3 angle values: 90
90
0
Triangle is NOT valid

Advertisement