C Program to Check if Triangle is Valid or Not using Angles

C Program to Check if Triangle is Valid or Not using Angles

Write a Program to Check if Triangle is Valid or Not using Angles

// C Program to Check if Triangle is Valid or Not using Angles

#include <stdio.h>

int main()
{
    int angle1, angle2, angle3, total;

    printf("Enter Angle 1 :--> ");
    scanf("%d", &angle1);

    printf("Enter Angle 2 :--> ");
    scanf("%d", &angle2);

    printf("Enter Angle 3 :--> ");
    scanf("%d", &angle3);

    total = angle1 + angle2 + angle3 ;
    printf("\nSum of Angles :--> %d\n", total);
    if( total == 180)
    {
        printf("Sum of angle is 180, so It is a Valid Triangle\n");
    }
    else
    {
        printf("Sum of Angle is not 180, so, It is an invalid Triangle");
    }

    return 0;
}

Output:

Run - 1:
Enter Angle 1 :--> 50
Enter Angle 2 :--> 60
Enter Angle 3 :--> 70

Sum of Angles :--> 180
Sum of angle is 180, so It is a Valid Triangle

Run - 2:
Enter Angle 1 :--> 40
Enter Angle 2 :--> 50
Enter Angle 3 :--> 60

Sum of Angles :--> 150
Sum of Angle is not 180, so, It is an invalid Triangle