Sunday, August 31, 2014

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.


Code

#include<stdio.h>
#include<conio.h>
int main()
{
int angle1,angle2,angle3,sum;
printf ("Enter three angles of triangle: ");
scanf("%d%d%d",&angle1,&angle2,&angle3);
sum=angle1+angle2+angle3;
if(sum==180)
{
printf("\nTriangle is valid");
}
else
printf("\nTriangle is invalid");

printf ("\n\nPress any key to close.");

getch ();
return 0;
}

Output

triangle validity c language

3 comments :

Note: Only a member of this blog may post a comment.

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact