

C++ program to find the perimeter and area of triangle
source link: https://www.geeksforgeeks.org/videos/cpp-program-to-find-the-perimeter-and-area-of-triangle/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

C++ program to find the perimeter and area of triangle
- 20 Views
- 22/09/2022
In this video, we will write a C++ program to find the perimeter and area of a triangle. Triangles are three-sided collective polygons formed by the intersection of three lines. It consists of three sides, three angles, and three vertices.
Area of a triangle:
The area of a triangle is defined as the total space occupied by the three sides of a triangle in a 2- dimensional plane.
Formula:
A = 1/2 × b × h
The perimeter of the triangle:
To calculate the perimeter of a triangle, we just add the length of its all sides. Suppose, if a triangle has sides x, y, and z, also the perimeter of that triangle will be:
P = (x+y+z)
Example:
Input h and b : 3 4
Output Area = 6
Perimeter = 10
Approach:
Step 1: Initialize six variables: a,b, c,s,area and perimeter.
Step 2: Take input of a,b, and c from the user.
Step 3: Calculate the value of s.
Step 4: Calculate the area and perimeter of the triable using the formula and store the value in respective variables.
Step 5: Print the area and perimeter of the triangle.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK