If the three sides of a triangle are entered through the keyboard, write a c program to check whether the triangle is isosceles, equilateral, scalene or right angled triangle Output:Enter the first side: 3 Enter the second side: 4 Enter the third side: 5 Triangle is right angled Enter the first side: 2 Enter the second side: 2 Enter the third side: 3 Triangle is isosceles. Enter the first side: 3 Enter the second side: 3 Enter the third side: 3 Triangle is equilateral.
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 Page 2
Output Enter Cost Price and Selling Price 5 10 Profit = 5 Enter Cost Price and Selling Price 12 8 Loss = 4 Enter Cost Price and Selling Price 10 10 No Profit and No Loss Related Topics If the three sides of a Triangle are entered through the keyboard, write a program to check whether the Triangle is isosceles, equilateral, scalene Triangle. Note: Isosceles Triangle: A Triangle is called isosceles triangle if length of 2 sides of it are equal. Scalene Triangle: A Triangle is called scalene triangle if length of all 3 sides are different or not equal. Output 1:Enter values for a, b and c101010 It’s an Equilateral Triangle View Discussion Improve Article Save Article Like Article View Discussion Improve Article Save Article Like Article Given three integers as X, Y, and Z representing the three sides of a triangle, the task is to check whether the triangle formed by the given sides is equilateral, isosceles, or scalene.
Examples:
Approach: Follow the steps below to solve the problem:
Below is the implementation of the above approach:
Time Complexity: O(1) |