Q: Write a C++ Program to input three sides of a triangle. The

Where s = ( a+b+c ) / 2

**program then calculates the Area of triangle by the formula**Formula of area of triangle when 3 sides given |

## Write Down Algorithm of C++ Program Area of Triangle

1. Start

2. Input a,b,c

3. Calculate s = (a + b + c ) / 2

4. Calculate area = sqrt( s*(s-a)*(s-b)*(s-c))

5. print "Area of Triangle=", area

6. End

### Develop Flowchart of C++ Program Area of Triangle

develop flowchart c plus plus program area of triangle |

Generally we prepare a flowchart and algorithm which is independent of any programming language so here is a better flowchart version for

**with mathematical formula instead of C++ arithmetic expressions.**__C++ Program Area of Triangle__#### Flowchart for C++ Program How To Calculate Area of triangle when 3 side are input

develop flowchart c plus plus program area of triangle programming language independent |

### Source code for modern C++ IDEs /Compilers ( Used Dev C++ )

#include<iostream> #include<math.h> using namespace std; int main( ) { float a,b,c,s,area; cout<<"Enter side A of triangle = "; cin>>a; cout<<"Enter side B of triangle = "; cin>>b; cout<<"Enter side C of triangle = "; cin>>c; s = (a + b + c ) / 2; area = sqrt ( s * (s - a ) * (s - b ) * (s - c ) ) ; cout<< "Area of Triangle = "<<area; return 0; }

### Output of the sample run:

Enter side A of triangle = 5

Enter side B of triangle = 5

Enter side C of triangle = 5

Area of Triangle = 10.8253

--------------------------------

Process exited after 4.697 seconds with return value 0

Press any key to continue . . .

### Write Down Source Code of C++ Program Area of Triangle for Turbo C++ 3.0 Compiler / IDE

**#include<iostream.h>**

**#include<conio.h>**

**#include<math.h>**

**void main( )**

**{**

**float a,b,c,s,area;**

**clrscr();**

**cout<<"Enter side A of triangle = ";**

**cin>>a;**

**cout<<"Enter side B of triangle = ";**

**cin>>b;**

**cout<<"Enter side C of triangle = ";**

**cin>>c;**

**s = (a + b + c ) / 2;**

**area = sqrt ( s * (s - a ) * (s - b ) * (s - c ) ) ;**

**cout<< "Area of Triangle = "<<area;**

**getch();**

**}**

Nice C program Compute area of Triangle Input Three Sides on easycodebook.com

ReplyDeleteIt is really nice to look at the Nice Program to calculate Area of Triangle by Three sides Heron's formula, see C version of the same program

ReplyDelete