To Check the Given Triangle is Isocles , Equilateral or Right Angled Triang

ashine80

To Check the Given Triangle is Isocles , Equilateral or Right Angled Triang

254 Views
About the Author
#include<stdio.h>
    #include<ctype.h>
    #include<conio.h>
    #include<math.h>
    
    int main()
    {
      float Side1,Side2,Side3;
      float Flag1,Flag2,Sum_of_sq1,Sum_of_sq2,Sum_of_sq3;
      clrscr();
      printf("Enter Three Sides Side1 Side2 Side3 :");
      scanf("%f %f %f", &Side1 , &Side2 , &Side3);
      Flag1=(Side1==Side2)?(Side2==Side3?1:0):((Side2==Side3)?0:-1);
    	if(Flag1==0)
    	  { printf("Triangle is Isoceles\n");
    	    }
    	     if (Flag1==1)
    	      {  printf("Equilateral Triangle");
    		 }
    
    
    			  Sum_of_sq1=pow(Side1,2)+pow(Side2,2);
    			  Sum_of_sq2=pow(Side1,2)+pow(Side3,2);
    			  Sum_of_sq3=pow(Side2,2)+pow(Side3,2);
    			if (sqrt(Sum_of_sq1)==Side3 ||sqrt(Sum_of_sq2)==Side2 || sqrt(Sum_of_sq3)==Side1)
    			     printf("The Triangle is Right Angled Triangle");
    
    
    
    		 getch();
    		 return(0);
    
    }
Nutster 58 Newbie Poster

Because of the way that pow and sqrt are written internally, it is usually much more efficient to multiply doubles rather than using these functions for squaring operations.

{
    Sum_of_sq1 = Side1*Side1 + Side2*Side2;
    Sum_of_sq2 = Side1*Side1 + Side3*Side3;
    Sum_of_sq3 = Side2*Side2 + Side3*Side3;
    if (Sum_of_sq1==Side3*Side3 || Sum_of_sq2==Side2*Side2 || Sum_of_sq3==Side1*Side1)
        printf("The triangle is a right triangle.\n");
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.