# C++ Program to Calculate Area and Perimeter of Square Rectangle

## Calculate Area and Perimeter of Square and Rectangle in C++

To calculate area and perimeter of a square and rectangle in C++ Programming, you have to ask to the user to enter length and breadth of the rectangle and side length of the square and make two variable one for area and one for perimeter for each (square and rectangle), to perform mathematical calculation and display the result on the screen as shown here in the following program.

## C++ Programming Code to Calculate Area and Perimeter of Rectangle

Following C++ program ask to the user to enter the length and breadth of the rectangle to calculate and display the area and perimeter of the rectangle:

```/* C++ Program - Calculate Area and Perimeter of Rectangle */

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int len, bre, peri, area;
cout<<"Enter length and breadth of the rectangle :";
cin>>len>>bre;
area=len*bre;
peri=(2*len)+(2*bre);
cout<<"Area = "<<area<<"\tPerimeter="<<peri;
getch();
}```

When the above C++ program is compile and executed, it will produce the following result:

## C++ Programming Code to Calculate Area and Perimeter of Square

Following C++ program ask to the user to enter the side length of a square to calculate and display the area and perimeter of the square:

```/* C++ Program - Calculate Area and Perimeter of Square */

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int side, peri, area;
cout<<"Enter length of a side of square :";
cin>>side;
area=side*side;
peri=4*side;
cout<<"Area = "<<area<<"\tPerimeter="<<peri;
getch();
}```

When the above C++ program is compile and executed, it will produce the following result:

### Same Program in Other Language

You may like the same program in other programming languages:

Tools
Calculator