Question #48788

Given the lengths a,b,c of the sides of triangle, write a function based program to compute the area of the triangle., The formula for computing the area is given by:
Area = √ s(s-a)(s-b)(s-c)
where s is the semiparameter of the triangle
s=(a+b+c)/2

Expert's answer

//Header files

#include <iostream>

#include <math.h>

using namespace std;

// Create a main function

int main()

{

//Declaring Variables

double Area=0;

double a=0,b=0,c=0,s=0;

cout<<"Enter the lengthof side (a): ";

cin>>a;

cout<<"Enter thelength of side (b): ";

cin>>b;

cout<<"Enter thelength of side (c): ";

cin>>c;

//The formula for computing

s=(a+b+c)/2;

Area=sqrt(s*(s-a)*(s-b)*(s-c));

//Result

cout<<endl<<endl<<"The area ofthe triangle: "<<Area<<endl;

cin.get();

return 0;

}

#include <iostream>

#include <math.h>

using namespace std;

// Create a main function

int main()

{

//Declaring Variables

double Area=0;

double a=0,b=0,c=0,s=0;

cout<<"Enter the lengthof side (a): ";

cin>>a;

cout<<"Enter thelength of side (b): ";

cin>>b;

cout<<"Enter thelength of side (c): ";

cin>>c;

//The formula for computing

s=(a+b+c)/2;

Area=sqrt(s*(s-a)*(s-b)*(s-c));

//Result

cout<<endl<<endl<<"The area ofthe triangle: "<<Area<<endl;

cin.get();

return 0;

}

``

## Comments

## Leave a comment