Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Why doesn't it show any other triangle other than isoceles ?

0 votes
asked Jun 10, 2018 by Abhay Nayak (120 points)
#include <stdio.h>

int main()

{

  int a,b,c,b2,a2,c2;   

   printf("enter the three sides of a triangle ");

   scanf("%d%d%d",&a,&b,&c);

a2=a*a;

b2=b*b;

c2=c*c;

 if(a==b && b==c && c==a)

printf("its an equilateral triangle ");

else if((a==b && b!=c && a!=c) || (b==c && a!=b && c!=a)||(c==a && c!=b && a!=b))

printf("its an isoceles triangle ");

else if((a2+b2==c2)||(a2+c2==b2)||(c2+b2==a2))

printf("its a right angled triangle ");

else

printf("its a scalene triangle ");

}

1 Answer

+1 vote
answered Jun 12, 2018 by ris

#include <stdio.h>

int main()

{

  int a,b,c,b2,a2,c2;   

   printf("enter the three sides of a triangle ");

   scanf("%d%d%d",&a,&b,&c);

a2=a*a;

b2=b*b;

c2=c*c;

 if(a==b && b==c && c==a)

printf("its an equilateral triangle ");
else if((a2+b2==c2)||(a2+c2==b2)||(c2+b2==a2))
{
    if((a==b && b!=c && a!=c) || (b==c && a!=b && c!=a)||(c==a && c!=b && a!=b))
printf("its a right angled isoceles triangle ");
else
printf("its a right angled scalene triangle ");
}

else if((a==b && b!=c && a!=c) || (b==c && a!=b && c!=a)||(c==a && c!=b && a!=b))

printf("its an isoceles triangle ");


else if(a!=b!=c)

printf("its a scalene triangle ");


}

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...