Example 42: Area and Perimeter of a Triangle
Understand how to implement a C function that calculates the area and perimeter of a triangle based on three side lengths. Discover how pointers can be used to store and return these computed values, reinforcing your grasp of pointers and function design in C.
We'll cover the following...
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:
...