The area of a triangle can be calculated by inputting three sides of the triangle. How to program this calculation in C++? Let's share the programming with you.
Operation method
According to the three sides of the triangle, the area can be calculated by Helen formula.
First, define three real variables to save the length of three sides of the triangle.
Next, two real variables are defined to save the half perimeter and area of the triangle.
Then, you are prompted to enter the length of three sides of the triangle.
In the output window, enter the length of three sides of the triangle.
Calculate the value of half perimeter and save it in variable p.
Use Helen's formula to calculate the area of the triangle, and save it in the variable S.
Finally, output the area of the triangle.
Run the program, input the length of three sides of the triangle, and output the area of the triangle.