Tuesday, August 13, 2013

Write a c program to accept the length of three sides of a triangle from consol and to test and print the type of triangle Equilateral, Isoscale, Right angled, none of these.


#include<stdio.h>
#include<conio.h>


void main()
 {
  int a,b,c,p,q;
  clrscr();
  printf("Enter three sides of a triangle==>\n");

  scanf("%d%d%d",&a,&b,&c);
  if(a==b&&b==c&&c==a)
   {
    printf("Given triangle is an Equilateral triangle");

   }
  else
   if(a==b||b==c||c==a)
    {
     printf("Given triangle is an Isoscale triangle");

    }
   else
    if(a>b&&a>c)
     {
      p=(a*a);
      q=((b*b)+(c*c));
      if(p==q)
       {
printf("Given triangle is a Right Angle triangle");

       }
      else
       {
printf("None of these");
       }
     }
    else
     if(b>a&&b>c)
      {
       p=(b*b);
       q=((a*a)+(c*c));
       if(p==q)
{
printf("Given triangle is a Right Angle triangle");
}
       else
{
printf("None of these");
}
      }
     else
      if(c>a&&c>b)
       {
p=(c*c);
q=((a*a)+(b*b));
if(p==q)
{
 printf("Given triangle is a Right Angle triangle");

}
else
{
 printf("None of these");
}
       }
  getch();
 }







/**************************  OUTPUT WINDOW  ************************/


//-------------------  Equilateral triangle  ---------------------------

Enter three sides of a triangle==>
6
6
6
Given triangle is an Equilateral triangle

//--------------------  Isoscale triangle  -----------------------------

Enter three sides of a triangle==>
7
8
7
Given triangle is an Isoscale triangle

//-------------------  Right Angle triangle  ---------------------------

Enter three sides of a triangle==>
6
8
10
Given triangle is a Right Angle triangle

//---------------------  None of These  --------------------------------

Enter three sides of a triangle==>
8
11
19
None of these

No comments:

Post a Comment