A "Pythagorean Triple" is a set of integers which will make the sides of a right triangle when used in the calculation of Pythagoras’ Theorem. For example, "3, 4, 5" is a Pythagorean Triple. Write a short "C" function that takes three decimal integers and determines if they are a "Pythagorean Triple". The function should return a boolean which is true if the three numbers fit the pattern, and false otherwise. DO NOT write a "main()" method in this code! [15 pts.]

Answers

Answer 1

Answer:

The function in C is as follows:

bool checkPythagoras(int a, int b, int c ){

  bool chk = false;

  if(a*a == b*b + c*c || b*b == a*a + c*c || c*c == b*b + a*a){

      chk = true;

  }

  return chk;

}

Explanation:

This defines the function. It receives three integer parameters a, b and c

bool checkPythagoras(int a, int b, int c ){

This initializes the return value to false

  bool chk = false;

This checks if the three integers are Pythagorean Triple

  if(a*a == b*b + c*c || b*b == a*a + c*c || c*c == b*b + a*a){

If yes, the return value is updated to true

      chk = true;

  }

This returns true or false

  return chk;

}


Related Questions

Other Questions
Simplify this expression using the distributive property.2(2z+9) If the diameter is 111ft then the radius is anyone in the bay area? Which options are available when exporting a table definition and data? Check all that apply Find the area of composite figure What is role of force on the speed of moving object? Angle RelationshipsUse a calculator to find the approximate value of the expression. Round the answer to two decimal places.The cosine of the complimentary angle to 38a. 0.68b. -0.16c. -0.22d. 0.62Please select the best answer from the choices provided What similarities do Gatsby and the speaker of the poem, Invictus, possess? Based on your analysis of both characters, what are possible themes of both texts? Are they similar? In what ways are they similar or different? Determine the amplitude of the trigonometric function: *attached image* 4) Jenee made a 99, 86, 76, and 95 on her first four spelling tests. Her mother told herthat her spelling test average had to be a 91 for Jenee to get a new video game. Whatdoes Jenee need to make on her next test? HELP ME PLZ AN DTHANK YOU Brainliest pls helpFind the surface area and volume of the prism. Round your answer to nearest tenth. Can someone please help me ASAP Someone Please help :( A teacher would like to estimate the mean number of steps students take during the school day. To do so, she selects a random sample of 50 students and gives each one a pedometer at the beginning of the school day. They wear the pedometers all day and then return them to her at the end of the school day. From this, she computes the 98% confidence interval for the true mean number of steps students take during the school day to be 8,500 to 10,200. If the teacher had used a 90% confidence interval rather than a 98% confidence interval, what would happen to the width of the interval The police-community relations movement (PCR) developed out of the: Please help. Determine which lines are parallel and which are perpendicular. Explain your reasoning. PLEASE I NEED HELP! I WILL GIVE BRAINLIEST IF YOUR ANSWER IS CLEAR!!!!! ALSO NO LINKS PLEASE! If 36g of Al react with 34L of Oz, how many moles of Al2O3 are produced?4Al +302 --> 2Al2O3145 moles0.667 moles0.165 moles101 moles Find the volume of the prism