WAP to input all side of triangle and check whether triangle is Equilateral, Isosceles or Scalene Triangle

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
·                     C printf and scanf functions
·                     If Else statement in C
·                     Relational operators in C
·                     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


Comments

Most Viewed

Write C program to enter any year and check whether year is leap year or not using conditional/ternary operator.

WAP to input week number and print week day name.

C Program to Find Third Angle of a Triangle