Classifying Triangles

This is a simple program to check for given sides if the triangle is possible or not. If possible then it can classify as Right Angled, Equilateral, Isosceles or Scalene.

/* 
 Classifying Triangle 
 Enter the three sides a,b and c with space between them
*/
#include<stdio.h>
void main()
{
int a,b,c; 
    scanf("%d %d %d",&a, &b, &c); 
 if((a+b >c)&&(b+c > a)&& (c+a>b))
 {
   if( ( a*a==(b*b)+(c*c)) || ( b*b==(a*a)+(c*c)) || ( c*c==(a*a)+(b*b)))
    printf("Right-angle Triangle");
   else if( (a==b) && (b == c))
    printf("Equilateral Triangle");
   else if((a == b) || (b == c) || (c == a))
    printf("Isosceles Triangle");
   else printf("Scalene Triangle");
 } 
 else
 printf("Triangle is not possible");

 return;
}

About Sumant Sumant

I love Math and I am always looking forward to collaborate with fellow learners. If you need help learning math then please do contact me.
This entry was posted in Computer Program, Geometry, Programming and tagged , . Bookmark the permalink.

Leave a comment