In C++ please.
If the hypotenuse and one leg of a right triangle are equal to the hypotenuse and one leg of another right triangle, then the two right triangles are congruent.Assume that you are given a function called rightTriangle. It takes three sides of a triangle (the third parameter is the largest, so it will be the hypotenuse if the triangle is a right triangle) and returns true if the triangle is a right triangle and false otherwise. YOU DO NOT HAVE to WRITE THIS FUNCTION. YOU HAVE IT!Also assume that you have a function called equalNums. It takes 4 parameters, if the first 2 are == to the last 2, the function returns false, otherwise the function returns true. So if we send it 3 5 3 5 the function returns true. You do not have to write this function, you have it!Assume that the following variables are declared for two triangles and have values and we know that the 3rd side is the largest side:int triangle1Side1, triangle1Side2, triangle1Side3;int triangle2Side1, triangle2Side2, triangle2Side3;1. Write code in main (using the two functions that you have) to print out whether of not these two triangles are right congruent triangles. (remember that to be right congruent triangles, both triangles need to be right triangles and the hypotenuse and leg of one need to be == to the hypontenuse and leg of the other).

Respuesta :

Answer:

Following are the code to this question:

#include <iostream>//defining header file  

using namespace std;    

bool rightTriangle(int s1,int s2,int s3) //defining method rightTriangle  

{

int t1,t2,t3; //defining integer variables

t1 = s1*s1; // multiplying side value and store it into declaring integer  variables

t2 = s2*s2; // multiplying side value and store it into declaring integer variables

t3 = s3*s3;  // multiplying side value and store it into declaring integer variables

if(t3 == t1+t2)//use if block to check Pythagoras theorem

{

return true; //return true

}

else //else block

{

return false; //return false

}

}

bool equalNums(int n1,int n2,int n3,int n4) //defining method equalNums  

{

if(n1==n3 && n2==n4) //defining if block that checks  

{

return true;//return value true  

}

else //else block  

{

return false; //return value false

}

}

int main()//defining main method

{  

int t1=3,t2=4,t3=5,t11=3,t12=4,t13=5; //declaring integer varibles and assign value  

int check=0;   //defining integer varible check that checks values

if(rightTriangle(t1,t2,t3)&&rightTriangle(t11,t12,t13)) //defining codition to check value using and gate

{

if(equalNums(t1,t3,t11,t13) || equalNums(t2,t3,t12,t13)) // defining conditions to check value using or gate

check = 1; //if both conditions are true

}

if(check==1) //if block to check value is equal to 1

{

cout << "Right Congruent Triangles"; //print message

}

else//else block

{

   cout << "Not Right Congruent Triangles";//print message

}

}

Output:

Right Congruent Triangles

Explanation:

  • In the above-given code, a boolean method "rightTriangle" is declared, in which it accepts three integer variable "s1, s2, and s3" as a parameter, inside the method three another variable "t1, t2, and t3" is declared, in which parameter stores its square value.
  • In the next line, a conditional statement is declared that checks the "Pythagoras theorem" value and returns its value.  
  • In the next step, another method "equalNums" is declared, that accepts four integer parameter "n1, n2, n3, and n4", inside the method a conditional statement is used that uses an operator to check n1, n3, and n2, n4 value if it is true it will return true value else it will return false.
  • Inside the main method, integer variable and a check variable is defined that uses the if block to passes the value into the method and checks its return value is equal if all the value is true it will print the message "Right Congruent Triangles" else "Not Right Congruent Triangles".