C Programming Code Examples C > If Else and Switch Case Code Examples check whether triangle is equilateral, scalene or isosceles check whether triangle is equilateral, scalene or isosceles Write a C program to input sides of a triangle and check whether a triangle is equilateral, scalene or isosceles triangle using if else. How to check whether a triangle is equilateral, scalene or isosceles triangle in C programming. Properties of triangle A triangle is said Equilateral Triangle, if all its sides are equal. If a, b, c are three sides of triangle. Then, the triangle is equilateral only if a == b == c. A triangle is said Isosceles Triangle, if its two sides are equal. If a, b, c are three sides of triangle. Then, the triangle is isosceles if either a == b or a == c or b == c. A triangle is said Scalene Triangle, if none of its sides are equal. Logic to check equilateral, scalene or isosceles triangle Input sides of a triangle from user. Store it in some variables say j1, j2 and j3. Check if(j1 == j2 && j2 == j3), then the triangle is equilateral. If it is not an equilateral triangle then it may be isosceles. Check if(j1 == j2 || j1 == j3 || j2 == j3), then triangle is isosceles. If it is neither equilateral nor isosceles then it scalene triangle. #include <stdio.h> int main() { int j1, j2, j3; /* Input sides of a triangle */ printf("Enter three sides of triangle: "); scanf("%d%d%d", &j1, &j2, &j3); if(j1==j2 && j2==j3) { /* If all sides are equal */ printf("Equilateral triangle."); } else if(j1==j2 || j1==j3 || j2==j3) { /* If any two sides are equal */ printf("Isosceles triangle."); } else { /* If none sides are equal */ printf("Scalene triangle."); } return 0; }