Monday, May 1, 2023

Find a given triangle (with 3 sides) valid or not

 //find a given triangle (with 3 sides) valid or not 

#include "stdio.h"

int main ()

{

int s1,s2,s3;

printf ("Enter three sides :\n");

scanf ("%i%i%i",&s1,&s2,&s3);

if (s1+s2>s3 && s3>s2 && s3>s1)

{

printf ("The triangle is valid \n");

}


else if (s1+s3>s2 && s2>s3 && s2>s1)

{

printf ("The triangle is valid \n");

}

else if (s2+s3>s1 && s1>s2 && s1>s3)

{

printf ("The triangle is valid \n");

}

else if (s1==s2 && s2==s3 && s3==s1)

{

printf ("The triangle is valid \n");

}

else 

{

printf ("The triangle is not valid \n");

}

return 0;

}

                     output               output                otuput              output      

Enter three sides :

3

4

5

The triangle is valid

                                                                              or 

Enter three sides :

5

5

5

The triangle is valid

                                                    or 

Enter three sides :

5

5

4

The triangle is not valid

No comments:

Post a Comment

print a multiplication table of any integer taking from user

 // print a multiplication table of any integer taking from user  #include "stdio.h" int main () { int n,mul,i; printf ("...