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".