C Program To Check Whether The Triangle Is Equilateral, Isosceles Or ...

  • Home
  • Whiteboard
  • Online Compilers
  • Practice
  • Articles
  • AI Assistant
  • Jobs
  • Tools
  • Corporate Training
  • Courses
  • Certifications
Menu Categories Login
  • Switch theme
  • SQL
  • HTML
  • CSS
  • Javascript
  • Python
  • Java
  • C
  • C++
  • PHP
  • Scala
  • C#
  • Tailwind CSS
  • Node.js
  • MySQL
  • MongoDB
  • PL/SQL
  • Swift
  • Bootstrap
  • R
  • Machine Learning
  • Blockchain
  • Angular
  • React Native
  • Computer Fundamentals
  • Compiler Design
  • Operating System
  • Data Structure and Algorithms
  • Computer Network
  • DBMS
  • Excel
Technical Questions and Answers
  • Data Structure Data Structure
  • Networking Networking
  • RDBMS RDBMS
  • Operating System Operating System
  • Java Java
  • MS Excel MS Excel
  • iOS iOS
  • HTML HTML
  • CSS CSS
  • Android Android
  • Python Python
  • C Programming C Programming
  • C++ C++
  • C# C#
  • MongoDB MongoDB
  • MySQL MySQL
  • Javascript Javascript
  • PHP PHP
  • 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 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.

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 Bhanu Priya Bhanu Priya Updated on: 2023-11-07T04:45:51+05:30

65K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started Print Page Previous Next Advertisements

Tag » Area Of Equilateral Triangle C Program