...

/

Example 42: Area and Perimeter of a Triangle

Example 42: Area and Perimeter of a Triangle

Learn how to calculate the area and perimeter of a triangle using pointers.

We'll cover the following...

Problem

Write a function that calculates the area and perimeter of the triangle. It receives three sides of a triangle along with two pointers to store the results as parameters.

If the lengths of the sides of a triangle are denoted by a, b, and c, then the area of a triangle is given by:

area=S(Sa)(Sb)(Sc)area = \sqrt{S(S - a)(S - b)(S - c)} ...