# Program To Find Area and Perimeter of Rectangle in C++

This program is made to find area and perimeter of rectangle in C++.

## Area and Perimeter of Rectangle:

A rectangle is a four sided figure with two pairs of parallel lines. Each set of parallel lines has the same length. Area of rectangle is the number of square units inside the rectangle. Area of rectangle is measured by multiplying width and height. So the formula would be:

**AREA = WIDTH * HEIGHT**

The perimeter of a rectangle is the distance around the outside of the rectangle. The formula for perimeter is:

**PERIMETER = 2 * (WIDTH + HEIGHT)**

Recommended reading: Finding Factorial of A Number in C++

## Code To Find Area and Perimeter of Rectangle in C++ :

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include<iostream> using namespace std; int main() { int w,h,area,perimeter; cout<<"**CALACULATE AREA AND PERIMETER**"; cout<<endl<<"ENTER WIDTH OF RECTANGLE = "; cin>>w; cout<<"ENTER HEIGHT OF RECTANGLE = "; cin>>h; area=h*w; cout<<endl<<"AREA OF RECTANGLE: "<<area<<endl; perimeter=2*(h+w); cout<<"PERIMETER OF RECTANGLE: "<<perimeter<<endl; return 0; } |

## Code Explanation:

First of all, we declared four integer type variables named **h**, **w**, **area **& **perimeter**.

Height is denoted by **h **and Width is denoted by **w**.

After getting input from user, we used following formulas to calculate area and perimeter of rectangle.

1 2 |
area=h*w; perimeter=2*(h+w); |

After calculating the values, we printed them on screen using **cout** statement.

Recommended reading: How to Add Two Numbers in C++

## Program Output:

If you liked this article, then I would really appreciate if you follow us on __Twitter__ and __Facebook__.

If you have any question then you can ask me in comments. I would like to answer them.

You can also Click Here to Download Exercise Files.

Great yaar