Answer to Question #279460 in C++ for Kyut

Question #279460

The area of a triangle whose sides a, b, and c can be computed by the formula:


𝑨𝒓𝒆𝒂 𝒐𝒇 π‘»π’“π’Šπ’‚π’π’ˆπ’π’† = βˆšπ‘ ((𝑠 βˆ’ π‘Ž)(𝑠 βˆ’ 𝑏)(𝑠 βˆ’ 𝑐))


where S = (a+b+c)/2. On the other hand, the hypotenuse of a right triangle can be computed using the


formula:


3. π»π‘¦π‘π‘œπ‘‘π‘’π‘›π‘’π‘ π‘’ = βˆšπ‘Ž


2 + 𝑏


2 .


Write a program that can compute for the Area of a Triangle and the Hypotenuse of a right triangle. Your


program must allow the user to choose what computation to take first. Only one computation at a time. Use


a function for each computation. Allow the user to repeat the entire process as often as he/she wants

1
Expert's answer
2021-12-15T02:09:43-0500
#include <bits/stdc++.h>
using namespace std;

int main()
{
Β  Β  Β  Β  double s, p, a, b, c, ta, tb, tc, ts;
Β  Β  Β  Β  cin >> a >> b >> c;
Β  Β  Β  Β  p = (a+b+c)/2;
Β  Β  Β  Β  s = sqrt(p*(p-a)*(p-b)*(p-c));
Β  Β  Β  Β  cout << s << '\n';
Β  Β  Β  Β  cin >> ta >> tb;
Β  Β  Β  Β  tc = sqrt(ta*ta+tb*tb);
Β  Β  Β  Β  cout << tc << ' ' << (ta*tb)/3;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog