C Function to test for a valid triangle.

/* C Function to test for a valid triangle */
#include <stdio.h>

int IsTriangle(int a,int b,int c);

int main()
{
	int a,b,c,find;
	printf("Enter 3 side of triangle A B C : \n");
	scanf("%d%d%d",&a,&b,&c);
	find=IsTriangle(a,b,c);
	if(find==1)
		printf("\nValid triangle ");
	else
		printf("\nInvalid triangle ");
	return 0;

}
int IsTriangle(int a,int b,int c)
{
	int chk;
	if(a+b>c && a+c>b && b+c>a)
		chk=1;
	else
		chk=0;
	return chk;
}

Output :
Enter 3 side of triangle A B C :
5
6
6

Valid triangle



Leave a comment