Sunday, September 9, 2018

20. WAP to check whether a triangle is valid or not where the 3 sides of the triangle are input through keyboard.

#include<stdio.h>
#include<conio.h>
void main()
{
   int a,b,c;
   printf("Enter the length of the sides of the triangle: ");
   scanf("%d%d%d",&a,&b,&c);        
   if( (a+b <= c) || (b+c <= a) || (c+a <= b) )
      printf("\nTriangle is invalid.");
   else
      printf("\nTriangle is valid.");
   getch();
}


Output:






Please have a look at the below lesson posted on my YouTube channel:


No comments:

Post a Comment