Hi,

I have the following problem ( triangle of sides a,b,c)

Write a void function that uses five parameters: 3 values are the length of the edges of the triangle, and 2 are reference parameter that compute the area and perimeter.

Make the function robust.

Note that not all combination of a,b,c produce a triangle.

the function should produce correct results for legal data and reasonable results for illegal combination.

This is what I wrote below.

The problem I have is that when I enter bad combination for the edges of the triangles, instead ofjust displaying "bad combination, it continues and compute the area and perimeter (even though the data are illegal.

Thank you.Code:#include<iostream> #include<cmath> using namespace std; int main() //driver program { double area,perimeter; int finish,a,b,c; void compute_area(double&,double&,double,double,double); a=8; b=8; c=30; compute_area(area,perimeter,a,b,c); cout << "The area of a triangle with sides of length " << a << " , " << b << " and " << c << " is " << area << "and the perimeter is "<<perimeter<< endl; cin>>finish;// to keep output window open return 0; }//end main // function void compute_area (double& area, double& perimeter, double a, double b, double c) { double s; if( (a<(b+c))||(b<(a+c))||(c<(b+a)) ) { cout<<"bad combination!"<<endl; return; } else { s = (a + b + c)/ 2.0;// semiperimeter area = sqrt (s*(s-a)*(s-b)*(s-c)); // area triangle perimeter=a+b+c; } return; }

B