C Program to Check Whether a Triangle is Equilateral, Isosceles or Scalene Triangle

In this C program, we will learn about how to check whether a given triangle is equilateral, isosceles or scalene triangle.

  • A triangle is equilateral triangle, If it's sides are equal.
  • A triangle is isosceles triangle, If any two sides of a triangle are equal.
  • A triangle is scalene triangle, If none of the sides are equal.

Required Knowledge


C program to check whether input triangle is equilateral, isosceles or scalene triangle

#include <stdio.h>  
  
int main() {  
    int side1, side2, side3;   
 
    printf("Enter Length of Three Sides of a Triangle\n");  
    scanf("%d %d %d", &side1, &side2, &side3);   
  
    if((side1 == side2)&&(side2 == side3)) {
        /* All Sides Equal, Hence Equilateral */  
        printf("It is an Equilateral Triangle\n");  
    } else if (side1!=side2 && side2!=side3 && side3!=side1) {
        /* All sides different, Hence Scelene */  
        printf("It is a Scalene Triangle\n");  
    } else {
        /* Two sides equal, Hence Isoscales */ 
        printf("It is an Isoscales Triangle\n");  
    }  
  
    return 0;  
}
Output
Enter Length of Three Sides of a Triangle
10 10 10
It is an Equilateral Triangle
Enter Length of Three Sides of a Triangle
10 10 5
It is an Isoscales Triangle
Enter Length of Three Sides of a Triangle
7 10 5
It is an Isoscales Triangle

Related Topics
C program to check whether three angles of triangle is valid or not
C Program to Check Whether a Triangle is Equilateral, Isosceles or Scalene Triangle
C Program to Calculate Area of a Right Angled Triangle
C Program to Calculate Area of Any Triangle using Heron's Formula
C Program to Find Third Angle of a Triangle
C Program to Print Floyd's Triangle
C Program to Print Triangle and Pyramid patterns of Star(*) Character Using Loop
C Program to Print Pascal Triangle till N Rows
C Program to Calculate Area and Perimeter of an Equilateral Triangle
List of all C programs