Now we will calculate area of triangle using C++ code and Hero’s Formula

## Hero’s Formula:

Hero’s formula is used to determine the are of triangle using its length of sides of triangle.

### Formula:

\text{ Area }=\sqrt{s(s-a)(s-b)(s-c)}

Given Question:

### Sides of triangle

a=7.6

b=9.8

c=16

## Code of Hero’s Formula

1- First of All we will specify the library and pre processive directives.

### Note: We are using <math.h> library because we are dealing with mathematics formulas.

```
#include <iostream>
#include <math.h>
using namespace std;
int main () {
}
```

2- Then we will specify Variables.

```
#include <iostream>
#include <math.h>
using namespace std;
int main () {
float side_a = 7.6;
float side_b = 9.8;
int side_c = 16;
}
```

3- Now we will add the value of s which is (a+b+c)/2.

```
#include <iostream>
#include <math.h>
using namespace std;
int main () {
float a = 7.6;
float b = 9.8;
int c = 16;
float s= (a+b+c)/2
}
```

4- Apply the formula and cout output.

**Note**: Square root in C++ is written as **sqrt(x)**

```
#include <iostream>
#include <math.h>
using namespace std;
int main () {
float a = 7.6;
float b = 9.8;
int c = 16;
float s= (a+b+c)/2;
float x = (s*(s-a)*(s-b)*(s-c));
float area = sqrt(x);
cout<<area;
}
```

## Output of Code:

Area will be displayed on the screen as follow: