(Sides of a Right Triangle) Write a function that reads three nonzero integers and determines whether they are the sides of a right-angled triangle. The function should take three integer arguments and return 1 (true) if the arguments comprise a right-angled triangle, and 0 (false) otherwise. Use this function in a program that inputs a series of sets of integers.
Hint: a^2+b^2=C^2
in c programming
Hello learner,
Thanks for asking.
The reqiured code is given as
#include<stdio.h>
int trianglecheck(int ,int ,int);
int main()
{
int a,b,c;
printf("Enter the sides of the triangle:");
scanf("%d%d%d",&a,&b,&c);
trianglecheck(a,b,c);
}
int trianglecheck(int a,int b,int c)
{
if((a*a+b*b==c*c)||(b*b+c*c==a*a)||(a*a+c*c==b*b))
printf("True");
else
printf("False");
}
In this code at first input is taken from the user for the three sides of the triangle. And then pythagoras therom is used to check all the three sides one by one which is a^2+b^2=C^2.
when any of the equation fulfill the the condition of pythagoras theorem then it prints true otherwise it prints false.
please upvote and ask if you have any query.
Get Answers For Free
Most questions answered within 1 hours.