**Introduction**

This post will Teach you to create a program in C++ to Calculate the perimeter of different shapes.The first one will calculate the perimeter of Square. The next will calculate perimeter of Circle. The next one will calculate perimeter of Rectangle. And the last one will calculate the perimeter of Equilateral Triangle. So you can create more program for more different shapes. Go enjoy the program. Lets begin…………………..

**Program to calculate perimeter of square**

#include<iostream.h> #include<conio.h> void main() { //clear the screen. clrscr(); //declare variable type int int a,peri; //Input the side and save it in 'a' cout<<"Enter the side of square"<<endl; cin>>a; //calculate perimeter and save it in 'peri' peri=4*a; //show the output 'peri' cout<<"Perimeter of square is "<<peri; //get character getch(); }

**Output**

Enter the side of square

5

Perimeter of square is 20

**Program to calculate perimeter of circle**

#include<iostream.h> #include<conio.h> void main() { //clear the screen. clrscr(); //declare variable type float float a,peri; //Input the radius and save it in 'a' cout<<"Enter the radius of circle"<<endl; cin>>a; //calculate perimeter and save it in 'peri' peri=2*3.14*a; //show the output 'peri' cout<<"Perimeter of circle is "<<peri; //get character getch(); }

**Output**

Enter the radius of circle

2

Perimeter of circle is 12.56

**Program to calculate perimeter of Rectangle**

#include<iostream.h> #include<conio.h> void main() { //clear the screen. clrscr(); //declare variable type float float l,b,peri; //Input the length and breadth and save it in 'l' and 'b' respectively cout<<"Enter the length of rectangle"<<endl; cin>>l; cout<<"Enter the breadth of rectangle"<<endl; cin>>b; //calculate perimeter and save it in 'peri' peri=2*(l+b); //show the output 'peri' cout<<"Perimeter of rectangle is "<<peri; //get character getch(); }

**Output**

Enter the length of rectangle

2

Enter the breadth of rectangle

1

Perimeter of rectangle is 6

**Program to calculate perimeter of Equilateral Triangle**

#include<iostream.h> #include<conio.h> void main() { //clear the screen. clrscr(); //declare variable type float float a,peri; //Input the side and save it in 'a' cout<<"Enter the side of Equilateral Triangle"<<endl; cin>>a; //calculate perimeter and save it in 'peri' peri=3*a; //show the output 'peri' cout<<"Perimeter of Equilateral Triangle is "<<peri; //get character getch(); }

**Output**

Enter the side of Equilateral Triangle

2

Perimeter of Equilateral Triangle is 6

**How does it work**

- You enter the necessary inputs for calculation in and is saved in variables.
- The Perimeter is calculated according to perimeter formula and is saved in ‘peri’.
- Variable ‘peri’ is shown by cout.

**Extending it**

The program can be extended by using more different shapes of geometry. You can take the necessary inputs and calculate the perimeter of the given geometry.

**Explanation.**

- Include ‘iostream.h’ and ‘conio.h’ files.
- Add void main.
- Start program by first clearing the screen.
- Declare the variables as float (name the as you want.)
- Add cout and cin of variables of necessary inputs.(as shown in program)
- Calculate the peri of the variables and save them in ‘peri’ variable.
- Cout the ‘peri’ variable.

**At the end**

You learnt creating the c++ program of Perimeter of geometrical shapes. So now enjoy the program.

Please comment on the post and share it.

And like it if you liked.