-
Notifications
You must be signed in to change notification settings - Fork 0
/
Missing side of rectangular triangle
40 lines (32 loc) · 1.12 KB
/
Missing side of rectangular triangle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//This program asks you to enter the value of each side of triangle, then sends answer. It tells you the the value of missing side of rectangular triangle.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double FirstCathetusOfTriangle;
double SecondCathetusOfTriangle;
double HypotenuseOfTriangle;
cout << "Enter first cathetus of triangle, if unknown enter 0" << endl;
cin >> FirstCathetusOfTriangle;
cout << "Enter second cathetus of triangle, if unknown enter 0"<< endl;
cin >> SecondCathetusOfTriangle;
cout << "Enter hypotenuse of triangle, if unknown enter 0" << endl;
cin >> HypotenuseOfTriangle;
if(FirstCathetusOfTriangle == 0)
{
cout << "\n";
cout << sqrt(pow(HypotenuseOfTriangle,2)-pow(SecondCathetusOfTriangle,2));
}
else if (SecondCathetusOfTriangle == 0)
{
cout << "\n";
cout << sqrt(pow(HypotenuseOfTriangle,2)-pow(FirstCathetusOfTriangle,2));
}
else
{
cout << "\n";
cout << sqrt(pow(FirstCathetusOfTriangle,2)+pow(SecondCathetusOfTriangle,2));
}
return 0;
}