29. C Program To Find The Type of Triangle If 3sides are given.
How does this program work?
- In this program you are going to learn about how to find Type of Triangle using 3sides.
- Entered 3 Sides are Stored 3 Variables a,b,c .
- By using the below if conditions the correct type of Triangle is identified using C-Language.
Here is the code
#include <stdio.h>
int main(void)
{
int a,b,c;
printf("Enterthe lengths of 3sides of triangles\n");
scanf("%d%d%d",&a,&b,&c);
if((a*a)+(b*b)==(c*c) || (b*b)+(c*c)==(a*a) || (c*c)+(a*a)==(b*b))
{
printf("Right angled triangle\n");
}
else
if((a==b) && (b==c))
{
printf("Equilateral triangle\n");
}
else
if((a==b) || (b==c) || (c==a))
{
printf("Isosceles triangle\n");
}
else
if((a!=b && b!=c && c!=a))
{
printf("Scalene triangle\n");
}
return 0;
}