Question

(Sides of a Right Triangle) Write a function that reads three nonzero integers and determines whether...

(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

Homework Answers

Answer #1

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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
JAVA 4.35 (Sides of a Triangle) Write an application that reads three nonzero values entered by...
JAVA 4.35 (Sides of a Triangle) Write an application that reads three nonzero values entered by the user and determines and prints whether they could represent the sides of a triangle. Here's the code: import java.util.Scanner; class TriangleYN {    public static void main(String[] args) {        Scanner input = new Scanner(System.in);               double a;        double b;        double c;               System.out.print("Enter three sizes, separated by spaces(decimals values are acceptable):");...
Q.1. Write a program that accepts the lengths of three sides of a triangle as inputs....
Q.1. Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is an equilateral triangle. Q.2. Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is a right triangle. Recall from the Pythagorean theorem that in a right triangle, the square of one side equals the sum of the...
Please write code in C. Thank you! Write a program that reads a list of integers,...
Please write code in C. Thank you! Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input begins with an integer indicating the number of integers that follow. You can assume that the list will have at least 2 integers and less than 20 integers. Ex: If the input is: 5 10 5 3 21 2 the output is: 2 3 To achieve the above, first read...
Write a basic c++ program to check whether a triangle is valid or not if the...
Write a basic c++ program to check whether a triangle is valid or not if the three sides are given: A triangle is valid if the sum of its two sides is greater than the third side. Let’s say that a, b, c is the sides of the triangle. A valid triangle must satisfy all these conditions: a + b > c a + c > b b + c > a (2 points) Generate random numbers 1-15 inclusive for...
Write a program in python 3 that uses a custom function to generate a specified number...
Write a program in python 3 that uses a custom function to generate a specified number of random integers in a specified range. This custom function should take three arguments; the number of integers to generate, the lower limit for the range, and the upper limit for the range. Values for these arguments should be entered by the user in main. The custom function should display the random integers on one line separated by single spaces. The function should also...
Below is an example of an algorithm that determines whether a number is even or odd....
Below is an example of an algorithm that determines whether a number is even or odd. function is_even(number) if number % 2 == 0 then return True otherwise return False Write a program that generates 100 random numbers (between 1 and 1000), and keeps a count of how many of those random numbers are even and how many are odd. Implement the algorithm above (or your improved version) as a function, which is used to work out whether each number...
C++ 1. Modify the code from your HW2 as follows: Your triangle functions will now return...
C++ 1. Modify the code from your HW2 as follows: Your triangle functions will now return a string object. This string will contain the identification of the triangle as one of the following (with a potential prefix of the word “Right ”): Not a triangle Scalene triangle Isosceles triangle Equilateral triangle 2. All output to cout will be moved from the triangle functions to the main function. 3. The triangle functions are still responsible for rearranging the values such that...
Function Example: Write a Python function that receives two integer arguments and writes out their sum...
Function Example: Write a Python function that receives two integer arguments and writes out their sum and their product. Assume no global variables. def writer(n1, n2): sum = n1 + n2 product = n1*n2 print("For the numbers", n1, "and", n2) print("the sum is", sum) print("and the product is", product) ... 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both...
answer for how it would be evaluated in Java without writing a code for it. a)...
answer for how it would be evaluated in Java without writing a code for it. a) 17 + 2 - 5 / 5 b) 2 + 3 * 5 - 2 c) 3 * 2 / 3 + 8 d) 6 % 2 * 10 Problem 2 : Write an application in java that inputs one number consisting of 5 digits (e.g. 12345) from the user, separates the number into its individual digits and prints the digits separated from one...
I was asked to write a program in CodeBlocks. C++ format. I've written the first half...
I was asked to write a program in CodeBlocks. C++ format. I've written the first half of the code but I am using else and if statements. I feel like the code is too long to do a simple calculation. In CodeBlock when you build and run your code, a new terminal window opens (in windows a new console window) and you can enter your inputs there. It is not like eclipse that you enter your inputs in console view....