Description: An isosceles triangle is triangle with (at least) two equal sides.
An equilateral triangle is a triangle with all three sides of equal length
A scalene triangle is a triangle that has three unequal sides
Code
#include <stdio.h>#include <conio.h>
int main()
{
int side1,side2,side3,h;
printf("Enter 3 sides of triangle: ");
scanf("%d%d%d",&side1,&side2,&side3);
if(side1==side2&&side1==side3)
{
printf("\nEquilateral triangle ");
}
else if(side1==side2||side2==side3||side1==side3)
{
printf("\ntriangle is isoscelses ");
}
else if(side1!=side2&&side2!=side3&&side1!=side3)
printf("\n triangle is scalene");
if(side1>side2&&side1>side3)
{
h=sqrt(side2*side2+side3*side3);
if(side1==h)
printf("\ntriangle is right angled triangle");
else
printf("\ntriangle is not right angled triangle");
}
else if(side2>side1&&side2>side3)
{
h=sqrt(side1*side1+side3*side3);
if(side2==h)
printf("\ntriangle is right angled triangle");
else
printf("\ntriangle is not right angled triangle");
}
else if(side3>side1&&side3>side2)
{
h=sqrt(side1*side1+side2*side2);
if(side3==h)
printf("\ntriangle is right angled triangle");
else
printf("\ntriangle is not right angled triangle");
}
printf ("\n\nPress any key to close.");
getch ();
return 0;
}
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.