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

SHARE THIS ARTICLE |

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)

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

#include<iostream>
using namespace std;
int main()
 {
    int w,h,area,perimeter;
    cout<<"**CALACULATE AREA AND PERIMETER**";
    cout<<"\nENTER WIDTH OF RECTANGLE = ";
    cin>>w;
    cout<<"ENTER HEIGHT OF RECTANGLE = ";
    cin>>h;
    area=h*w;
    cout<<"\nAREA OF RECTANGLE: "<<area<<endl;
    perimeter=2*(h+w);
    cout<<"PERIMETER OF RECTANGLE: "<<perimeter<<endl;
    return 0;
 }

Output:

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

Thanks for reading this article. if you have any question then you can ask me in comments.

You can also Click Here to Download Exercise Files.