# Project 15

two-dimentional array & user defined function (100 points)

• Allow the user to enter "n" many sets of triangle sides.
• After you prompt the user for the number of triangles, enter a nested loop to fill a two-dimentional array with the sides. Using the example output below, your array will be filled in the following manner ;
```side[0][0] = 5.000    side[0][1] = 8.000    side[0][2] = 7.000
side[1][0] = 13.00    side[1][1] = 14.00    side[1][2] = 15.00
side[2][0] = 9.000    side[2][1] = 40.00    side[2][2] = 41.00
side[3][0] = 8.000    side[3][1] = 7.000    side[3][2] = 13.00 ```

This matrix indicates that each row is a set of triangle sides.

• After you fill the array and exit the nest loop, use a for loop to calculate the area of each triangle and to sum up all the areas. Inside the for loop, you should call a user defined function which does the actual calculating of the triangle area. Here is an example of how you can call your function in the for loop.
`area[i] = tri_area( side[i][0], side[i][1], side[i][2] )`

tri_area is the name of the user defined function. The parameters side[i][0], side[i][1], side[i][2] are the sides of each individual triangle. An example prototype for this function would be.

`float tri_area(float a, float b, float c)`
• Once inside the function, you can calculate the area with Hero's formula.
```Hero's formula
if a, b, and c are the sides of the triangle then,
s = (a + b + c) / 2 and the area = sqrt(s(s-a)(s-b)(s-c))```

Using the sample output as an example, after you exit the loop to calculate the areas you should have the following one-dimentional array filled.

`area[0] = 17.32   area[1] = 84.00   area[2] = 180.0   area[3] = 24.25`
• After finding each area and the sum of all areas, output the Triangle Report with a seperate nested loop.
• The areas should be displayed with four significant digits and the sum of all the areas should be displayed with five significant digits.
• Make sure your program can display the sample output below.
• Your code must be well documented. Also include your name, date, project number and a breif description of the program.

```
Sample output
How many triangle do you want to find the area of? : 4

Clear Screen Here

Entering sides for triangle 1
==================================

Please enter side 1 : 5
Please enter side 2 : 8
Please enter side 3 : 7

Clear Screen Here

Entering sides for triangle 2
==================================

Please enter side 1 : 13
Please enter side 2 : 14
Please enter side 3 : 15

Clear Screen Here

Entering sides for triangle 3
==================================

Please enter side 1 : 9
Please enter side 2 : 40
Please enter side 3 : 41

Clear Screen Here

Entering sides for triangle 4
==================================

Please enter side 1 : 8
Please enter side 2 : 7
Please enter side 3 : 13

Clear Screen Here

Area of Triangle Report
=============================================
Triangle   Side 1   Side 2   Side 3   Area
=============================================
1          5.000    8.000    7.000    17.32
2          13.00    14.00    15.00    84.00
3          9.000    40.00    41.00    180.0
4          8.000    7.000    13.00    24.25
=============================================
Total : 305.57```