C++ Program to Find Area and Perimeter of Parallelogram

In this C++ program, we will calculate perimeter and area of parallelogram. Before jumping to C++ program, let's first discuss about parallelogram and it's properties.

A parallelogram is quadrilaterals(having four sides) with opposite sides parallel and equal in length. Opposite angles of a parallelogram are also equal.
Properties of Parallelogram
  • Opposite angles of a parallelogram are equal.
  • Diagonals of a parallelogram divides each other in two equal half.
  • Opposite sides of a parallelogram are parallel and equal in length.
  • The sum of any two adjacent angles of a parallelogram are 180 degrees.

C++ Program to Find Area of Parallelogram

To calculate the area of parallelogram we need length of Base and Height.

  • Base : We can choose any side of a parallelogram as base to calculate area of parallelogram.
  • Height : Height of a parallelogram is the perpendicular distance between the base and it's opposite side.
Area of Parallelogram
The area of a parallelogram can be calculated by multiplying Base and Height.
Area of Parallelogram = B X H
Where,
  • B is the length of base of parallelogram.
  • H is the length of height of parallelogram.
C++ program to find area of parallelogram
#include <iostream>
using namespace std;
 
int main(){
    float base, height, area;
    cout << "Enter the base and height parallelogram\n";
    cin >> base >> height;
    
    // Area of parallelogram = base X height 
    area = base * height;
    cout << "Area of parallelogram : " << area;
     
    return 0;
}
Output
Enter the base and height parallelogram
8 5
Area of parallelogram : 40

C++ Program to find Perimeter of parallelogram

The perimeter of a parallelogram can be calculated by adding the length of all four sides of parallelogram. As we know the length of opposite sides of parallelogram are equal, we can add any two adjacent sides of parallelogram and then multiply it with 2 to get perimeter of parallelogram.

Perimeter of parallelogram
Perimeter of Parallelogram = 2X(S1 + S2)
Where, S1 and S2 are length of adjacent sides of parallelogram.
#include <iostream>
using namespace std;
 
int main(){
   float side1, side2, perimeter;
   cout << "Enter the length of adjacent sides of parallelogram\n";
   cin >> side1 >> side2;
   // Perimeter of parallelogram = 2X(side1 + side2)
   perimeter = 2*(side1 + side2);
   cout << "Perimeter of parallelogram : " << perimeter;

   return 0;
}
Output
Enter the length of adjacent sides of parallelogram
10 4
Perimeter of parallelogram : 28

Recommended Posts
C++ Program to Find Area and Circumference of a Circle
C++ Program to Make a Simple Calculator
C++ Program to Find GCD of Two Numbers
C++ Program to find length of string
C++ Program to Copy String Without Using strcpy
C++ Program to Find Largest Element of an Array
C++ Program to Delete a Word from Sentence
C++ Program to Find Transpose of a Matrix
C++ Program to Add Two Matrix
All C++ Programs