Question #279459

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


š‘Øš’“š’†š’‚ š’š’‡ š‘»š’“š’Šš’‚š’š’ˆš’š’† = āˆšš‘ ((š‘  āˆ’ š‘Ž)(š‘  āˆ’ š‘)(š‘  āˆ’ š‘))

Expert's answer

#include<iostream>
#include<cmath>
using namespace std;
int main(){
	cout<<"Enter the first side: \n";
	double a;
	cin>>a;
		cout<<"Enter the second side: \n";
	double b;
	cin>>b;
  cout<<"Enter the third side: \n";
	double c;
	cin>>c;
	double s = (a + b + c) / 2;
	
	double area = sqrt(s*(s-a) * (s-b) * (s-c));
	cout<<"The area of the triangle is: "<<area<<endl;
}
LATEST TUTORIALS
APPROVED BY CLIENTS