- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C Program to check whether the triangle is equilateral, isosceles or scalene
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.
Algorithm
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.
Program
Following is the C program to check whether the triangle is equilateral, isosceles or scalene −
#include<stdio.h> int main(){ int side1, side2, side3; printf("Enter sides of triangle:"); scanf("%d%d%d",&side1,&side2,&side3); if(side1 == side2 && side2 == side3) printf("The Given Triangle is equilateral
"); else if(side1 == side2 || side2 == side3 || side3 == side1) printf("The given Triangle is isosceles
"); else printf("The given Triangle is scalene
"); return 0; }
Output
Let us compile and run the above program that will produce the following result −
Run1: 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
- Related Articles
- The points ( (-4,0),(4,0),(0,3) ) are the vertices of a(A) right triangle(B) isosceles triangle(C) equilateral triangle(D) scalene triangle
- What is an scalene , equilateral , right angled triangle , obtuse angled triangle and a reflex angled triangle
- C++ Program to Check Whether Number is Even or Odd
- What is a Scalene Triangle?
- Program to calculate the Area and Perimeter of Incircle of an Equilateral Triangle What is Equilateral Triangle in C?
- C# program to check whether a list is empty or not
- C++ Program to Check Whether a Number is Prime or Not
- C++ Program to Check Whether a character is Vowel or Consonant
- C++ Program to Check Whether a Number is Palindrome or Not
- C Program to Check Whether a Number is Prime or not?
- C Program To Check whether Matrix is Skew Symmetric or not?
- C++ Program to check whether given password is strong or not
- C++ program to check whether given string is bad or not
- C++ Program to Check Whether a Number is Positive or Negative
- C++ Program to Check Whether a Character is Alphabet or Not

Advertisements