Introduction

Control Statement

- Program to Check Armstrong Number
- Program to find the sum of Natural Numbers using Recursion
- Calculator Program
- Program to identify day of week
- Program to print Fibonacci series
- Check Whether the Number is Even or Odd in C++
- Program to check whether the number is prime or not
- Program to check vowel or constant
- Program to check the largest number among three numbers

Function

- Program to find the area of triangle
- Program to find LCM
- Program to check prime number using Functions
- Program to convert Binary to Decimal Number
- Program to convert Decimal to Binary Number
- Program to convert Binary to Octal Number
- Program to convert Octal to Binary Number
- Program to find reverse of the sentence using Recursion
- Program to Shutdown and restart Computer

Array

Pointer

OOPS

No Examples found for this topic - CodeHelpPro

Mar 30

**2021**# Program to find the area of triangle

In this example, We will learn to calculate the area of a triangle. This program will calculate the area of any type of triangle.

We will use following formula to calculate area of the triangle

## Area of triangle

For detail explanation of area of a triangle, You can check this website.

Lets look an example to make clear concepts

## CODE:

```
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a, b, c;
cout << "Enter the three sides of the triangle\n";
//taking input from user
cin >> a >> b >> c;
//calculating s
float s = (float)(a + b + c) / 2;
//calculating area
float area = sqrt(s * (s - a) * (s - b) * (s - c));
//printing the area
cout << "Area of triangle = " << area << " sqt. unit" << endl;
return 0;
}
```

The output of above program is

```
Enter the three sides of the triangle
5
4
3
Area of triangle = 6 sqt. unit
```

Subscribe

Login

0 Comments

Inline Feedbacks

View all comments