The area of an arbitrary triangle can be computed using the formula area = √(s(s–a)(s–b)(s–c)) where the square root is applied to the entire product  and where a, b, and c are the lengths of the sides, and s is the semiperimeter  of the triangle given by the formula: s = (a + b + c)/2 Write a void function named  triangle  that computes the area and perimeter (as well as the semiperimeter (which will be used to compute the area) of a triangle based  on the length of the sides. The function should use five parameters and may call other functions. Make your function robust. Note that not all combinations of a, b, and c produce a triangle. Your function should produce correct results for legal data and reasonable results for illegal combinations. Include in your submission a driver that repeatedly reads in 3 positive numbers that are the sides of a triangle, and each time print out the sides and the area and perimeter calculated by the triangle function. Your program  should terminate when the first side typed  in a group of three is negative or zero.   Rubric Documentation 10 Void function declaration  20 Void function definition  40 Use of call by reference parameters  15 Successful run and output      15 Here is main. Do not edit.  int    main() {     double s1, s2, s3, p, a;     triangle(s1, s2, s3, p, a);     return 0; }

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section: Chapter Questions
Problem 7PP: (Numerical) Heron’s formula for the area, A, of a triangle with sides of length a, b, and c is...
icon
Related questions
Question

The area of an arbitrary triangle can be computed using the formula

area = √(s(s–a)(s–b)(s–c))

where the square root is applied to the entire product  and where a, b, and c are the lengths of the sides, and s is the
semiperimeter  of the triangle given by the formula:

s = (a + b + c)/2


Write a void function named  triangle  that computes the area and perimeter (as well as the semiperimeter (which will be used to compute the area)
of a triangle based  on the length of the sides. The function should use five parameters and may call other functions.
Make your function robust. Note that not all combinations of a, b, and c produce a triangle. Your function should produce correct results
for legal data and reasonable results for illegal combinations. Include in your submission a driver that repeatedly reads in 3 positive numbers that
are the sides of a triangle, and each time print out the sides and the area and perimeter calculated by the triangle function. Your program  should
terminate when the first side typed  in a group of three is negative or zero.

 

Rubric

Documentation 10

Void function declaration  20

Void function definition  40

Use of call by reference parameters  15

Successful run and output      15

Here is main. Do not edit. 

int    main()
{
    double s1, s2, s3, p, a;

    triangle(s1, s2, s3, p, a);

    return 0;
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr