write a C-program to check whether the triangle is isosceles, equilateral or scalene.

 TASK-

If the three sides of a triangle are entered through the keyboard, write a C-program to check whether the triangle is isosceles, equilateral or scalene, display the result accordingly. Your code should also determine and display whether the triangle is right angle triangle or not?



CODE:

#include<stdio.h>
int main(){

int a,b,c;

printf("Enter three sides of Triangle: ");

printf("\nA: ");
scanf("%d",&a);

printf("\nB: ");
scanf("%d",&b);

printf("\nC: ");
scanf("%d",&c);

// condition for equilateral triangle
if (a==b && a==c && b==c)
printf("\n\n This is an equilateral Triangle");

//condition for isosceles triangle
else if (a==b||b==c||c==a) 
printf("\n\n This is an isosceles Triangle");

// condition for scalene triangle
else if (a!=b && b!=c && a!=c)
printf("\n\n This is a scalene Triangle");

//Condition for Right angle triangle
if (a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b)
printf("\n\n This is a right angle triangle");

else
printf("\n\n This is not a right angle triangle");

getchar();
return 0;
}

Expected Output:




NEED WORK PRODUCE WORK

My name is Abdul Rehman I am from Pakistan. I am doing BS in Computer and information sciences. Currently, I am creating these blogs to help students of computer sciences all over the world..

Post a Comment (0)
Previous Post Next Post