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...
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...
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....
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads...
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads data from a file and performs regression analysis using polyfit and polyval. The function shall have the following features: The input arguments shall include the file name (string), a vector of integers for the degrees of polynomial fits to be determined, and an optional plot type specifier (‘m’ for multiple plots, ‘s’ for a single plot - default). The data files will be text...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using the following guidelines - Write two primary helper functions - one iterative (IsArrayPrimeIter) and one recursive (IsArrayPrimeRecur) - each of which Take the array and its size as input params and return a bool. Print out a message "Entering <function_name>" as the first statement of each function. Perform the code to test whether every element of the array is a Prime number. Print out...
Task 2: Compare strings. Write a function compare_strings() that takes pointers to two strings as inputs...
Task 2: Compare strings. Write a function compare_strings() that takes pointers to two strings as inputs and compares the character by character. If the two strings are exactly same it returns 0, otherwise it returns the difference between the first two dissimilar characters. You are not allowed to use built-in functions (other than strlen()) for this task. The function prototype is given below: int compare_strings(char * str1, char * str2); Task 3: Test if a string is subset of another...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • What is a management maintenance model? What does it accomplish? [MANAGEMENT OF INFORMATION SECURITY][Please provide a...
    asked 3 minutes ago
  • In recent years, different kinds of databases have emerged that do not adhere to the traditional...
    asked 4 minutes ago
  • List and describe the fields found in a properly and fully defined performance measure. [Please Describe...
    asked 5 minutes ago
  • A savvy group of graduate students are developing a new corporation, GraduateSchoolOrBust. Their mission is to...
    asked 10 minutes ago
  • Write a method called sumDiagonal() that takes a 2D array of int as an argument returns...
    asked 14 minutes ago
  • You roll two six-sided fair dice. a. Let A be the event that either a 3...
    asked 39 minutes ago
  • Consider the following reaction: A + 2B → E Using steady-state approximation determine which of the...
    asked 39 minutes ago
  • QUESTION: Study the following case, then prepare a context diagram and level zero diagram based on...
    asked 46 minutes ago
  • The pitch deck should be sent beforehand when pitching to competition judges early investors employees trade...
    asked 55 minutes ago
  • Understanding the Project Management Methodologies The project methodology is determined by the type of organization and...
    asked 1 hour ago
  • A yo-yo has a rotational inertia of 1000 g·cm2 and a mass of 127 g. Its...
    asked 1 hour ago
  • Compare and contrast Erikson's fifth stage of personality development and Marcia's theory on identity statuses. Which...
    asked 1 hour ago