Coding Practice

Write a C program to input angles of a triangle and check whether triangle is valid or not

Valid Triangle Check by Angles
Sample Output
Enter three angles...
40
50
60
Triangle is not valid.

Process returned 0 (0x0)   execution time : 7.433 s
Press any key to continue.
Source Code
#include<stdio.h>
int main()
{
int angle1, angle2, angle3;
printf("Enter three angles...\n");
scanf("%d %d %d", &angle1, &angle2, &angle3);
if(angle1 + angle2 + angle3 == 180)
{
printf("Triangle is valid.\n");
}
else
{
printf("Triangle is not valid.\n");
}
return 0;
}
Sample Output
Enter three angles...
45
45
90
Triangle is valid.

Process returned 0 (0x0)   execution time : 3.617 s
Press any key to continue.

No comments:

Post a Comment

Change Theme
X