Answer to Question #233125 in C++ for alex

Question #233125

Write and test the following computeTriangle() function that returns the area a and the

perimeter p of the triangle with given side lengths a, b, c:

void computeTriangle( float&, float&, float, float, float);


1
Expert's answer
2021-09-06T00:17:20-0400
#include<iostream>
#include<cmath>
using namespace std;
void computeTriangle(float&, float&, float, float, float);
int main(){
	cout<<"Testing computeTriangle() function\n";
	float perimeter, a, b, area, c;
	cout<<"Enter the side a\n";
	cin>>a;
	cout<<"Enter the side b\n";
	cin>>b;
	cout<<"Enter the side c\n";
	cin>>c;
	computeTriangle(area, perimeter, a, b,c);
	cout<<"Area is: "<<area<<"\nPerimeter is:   "<<perimeter<<endl;
}
void computeTriangle(float &area, float&perimeter, float a, float b, float c){
	perimeter = a+ b+c;
	float s = perimeter / 2;
	area = sqrt(s*(s-a)*(s-b)*(s-c));
}

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
APPROVED BY CLIENTS