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

• Write a C program to check whether input triangle is equilateral, isosceles or scalene triangle using if else statement.

#### Required Knowledge

• 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.

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

```/*
* Write a C program to check whether a Triangle is Equilateral,
* Scalene or Isosceles
*/

#include <stdio.h>

int main() {
int side1, side2, side3;
/*
* Take length of three sides of triangle as input
* from user using scanf
*/
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