# C program to check triangle is Equilateral, Isosceles or Scalene

Before going to the program to check triangle is *Equilateral, Isosceles or Scalene* first let us understand what is a *Equilateral, Isosceles or Scalene Triangle?*

**Equilateral Triangle:**

A *Triangle *is said to be an *Equilateral Triangle* if all the three sides are equal.

**Isosceles Triangle:**

A *Triangle *is said to be an *Isosceles Triangle* if its two side are equal.

**Scalene Triangle:**

A *Triangle *is said to be an *Scalene Triangle* if all the three sides are different.

## Program code to check Equilateral, Isosceles or Scalene Triangle:

#include<stdio.h> #include<conio.h> void main() { int a, b, c; clrscr(); printf("\n\n Enter three sides of triangle: "); scanf("%d %d %d", &a, &b, &c); if(a<=0 || b<=0 || c<=0) { printf("\n INVALID INPUT"); } else if(a==b && b==c) { printf("\n Equilateral Triangle"); } else if(a==b || a==c || b==c) { printf("\n Isosceles Triangle"); } else { printf("\n Scalene Triangle"); } getch(); }

## Step by Step working of the above Program Code:

**For Invalid Input:**

- Let us assume that the user enters the three sides of triangle as 4 0 4.
- So it assigns the value of
**a=4, b=0, c=4.** - a<=0 or b<=0 or c<=0 (4<=0 or b<=0 or c<=0) if condition is true
- So it prints as
**INVALID INPUT.**

- So it prints as
- Thus the program execution is completed.

**For Equilateral Triangle:**

- Let us assume that the user enters the three sides of triangle as 10 10 10.
- So it assigns the value of
**a=10, b=10, c=10.** - a<=0 or b<=0 or c<=0 (10<=0 or 10<=0 or 10<=0) if condition is false
- So it goes to next
**else if**part**.**

- So it goes to next
- a==b and b==c (10==10 and 10==10) if condition is true
- So it prints as
**Equilateral Triangle.**

- So it prints as
- Thus the program execution is completed.

**For Isosceles Triangle:**

- Let us assume that the user enters the three sides of triangle as 30 20 30.
- So it assigns the value of
**a=30, b=20, c=30.** - a<=0 or b<=0 or c<=0 (30<=0 or 20<=0 or 30<=0) if condition is false
- So it goes to next
**else if**part**.**

- So it goes to next
- a==b and b==c (30==20 and 20==30) if condition is false
- So it goes to next
**else if**part**.**

- So it goes to next
- a==b or a==c or b==c (30==20 or 30==30 or 20==30) if condition is true
- So it prints as
**Isosceles****Triangle.**

- So it prints as
- Thus the program execution is completed.

**For Scalene Triangle:**

- Let us assume that the user enters the three sides of triangle as 10 20 30.
- So it assigns the value of
**a=10, b=20, c=30.** - a<=0 or b<=0 or c<=0 (10<=0 or 20<=0 or 30<=0) if condition is false
- So it goes to next
**else if**part**.**

- So it goes to next
- a==b and b==c (10==20 and 20==30) if condition is false
- So it goes to next
**else if**part**.**

- So it goes to next
- a==b or a==c or b==c (10==20 or 10==30 or 20==30) if condition is false
- So finally it goes to
**else**part and prints as**Scalene Triangle.**

- So finally it goes to
- Thus the program execution is completed.

## Output:

### TO DOWNLOAD THE PROGRAM CODE : CLICK HERE