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