C Program to check whether the triangle is equilateral, isosceles or scalene

CServer Side ProgrammingProgramming

Triangle consists of three sides and three angles. Based on the three sides, there are three types of triangle −

  • Equilateral triangle: All three sides are equal.
  • Isosceles triangle: All two sides are equal.
  • Scalene triangle: No sides are equal.

Follow the algorithm given below for writing the respective program.


Step 1: Declare three sides of triangle.
Step 2: Enter three sides at run time.
Step 3: If side1 == side2 && side2 == side3
Go to step 6
Step 4: If side1 == side2 || side2 == side3 || side3 == side1
Go to Step 7
Step 5: Else
Go to step 8
Step 6: Print the triangle is equilateral.
Step 7: Print the triangle is isosceles.
Step 8: Print the triangle is scalene.


Following is the C program to check whether the triangle is equilateral, isosceles or scalene −

 Live Demo

int main(){
   int side1, side2, side3;
   printf("Enter sides of triangle:");
   if(side1 == side2 && side2 == side3)
      printf("The Given Triangle is equilateral\n");
   else if(side1 == side2 || side2 == side3 || side3 == side1)
      printf("The given Triangle is isosceles\n");
      printf("The given Triangle is scalene\n");
   return 0;


Let us compile and run the above program that will produce the following result −

Enter sides of triangle:3 4 6
The given Triangle is scalene
Run2 :
Enter sides of triangle:2 2 5
The given Triangle is isosceles
Run 3:
Enter sides of triangle:5 5 5
The Given Triangle is equilateral
Published on 12-Mar-2021 11:02:20