C++ Programming Code Examples C++ > Computer Graphics Code Examples Calculate Area and Perimeter of Rectangle Calculate Area and Perimeter of Rectangle 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. 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: #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(); }