2. The area of a triangle whose sides a, b, and c can be computed by the formula:
π¨πππ ππ π»πππππππ = βπ ((π β π)(π β π)(π β π))
#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;
}
Comments
Leave a comment