# C# Program to Find the Perimeter of Circle and Rectangle

This is a C# Program to calculate primeter of circle and rectangle.

Problem Description

This C# Program Calculates Perimeter of Circle and Rectangle.

Problem Solution

Here length and breadth of the rectangle and radius of the circle is also obtained and perimeter of circle and rectangle is calculated.

Program/Source Code

Here is source code of the C# Program to Calculate Perimeter of Circle and Rectangle. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

```/*
* C# Program to Calculate Perimeter of Circle and Rectangle
*/
using System;
using System.IO;
class program
{
public static void Main()
{

double l,b,r,per_rect,per_cir;
double PI = 3.14;
Console.WriteLine("Enter the Length and Breadth : ");
per_rect = 2 * (l + b);
Console.WriteLine("Enter the radius of the circle : ");
per_cir = 2 * PI * r;
Console.WriteLine("Perimeter of Rectangle : {0}", per_rect);
Console.WriteLine("Perimeter of Circle : {0}", per_cir);
}
}```
Program Explanation

In this C# program, library function defined in <math.h> header file is used. We are reading the length and breadth using ‘l’ and ‘b’ variables respectively. To compute the perimeter of a rectangle the following formula is used

perimeter = 2 * (l + b).

We are reading the radius of the circle using ‘r’ variable. To compute the perimeter of circle the formula is used

perimeter = 2 * PI * r

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

where PI = 22/7.

Runtime Test Cases
```
Enter the Length and Breadth :
3
2
Enter the radius of the circle :
4
Perimeter of Rectangle : 10
Perimeter of Circle : 25.12```

Sanfoundry Global Education & Learning Series – 1000 C# Programs. 