# Program to find the area of the parallelogram in C++

In this c++ program, we will calculate the area of the parallelogram. Before going to the program let us know what is a parallelogram. A parallelogram is a four-sided quadrilateral with both the opposite sides to parallel to each other and equal. So let’s start learning how to find the area of a parallelogram in C++.

To calculate the area of the parallelogram we need the length of base and height. From the figure, we can see AB||CD and AC|| BD. Consider CD as the base then height is the perpendicular distance between the base and it’s opposite side. Here AE is the height of the parallelogram.

**FORMULA FOR AREA OF THE PARALLELOGRAM:**

*Area of the parallelogram=base * height.*

From the figure CD i.e.’b’ is the base and AE i.e, ‘h’ is the height of the parallelogram.

Area=b*h.

## C++ program to find area of a parallelogram

There are 2 ways to initialise the variables in the program.

Compile time and Run time

**Syntax for compile time initialisation:**

float base=13.5;

float height=12.7;

float area=base * height;

**Source code:**

int main() { float base=13.5; float height=12.7; float area =base * height; cout<<"area of the parallelogram is "<<area; return 0; }

Output:

area of the parallelogram is 171.450000.

**Syntax for run time initialisation:**

float base,height,area;

cin>>base>>height;

area=base*height;

**Source code:**

int main() { float base,height,area; cout<<"enter base value:"; cin>>base; cout<<"\n enter height value:"; cin>>height; area=base*height; cout<<"\n area of parallelogram is "<<area; return 0; }

Output:

enter base value:13.5 enter height value:12.7 area of parallelogram is 171.45000.

You may also read:

## Leave a Reply