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

This C# Program Calculates Perimeter of Circle and Rectangle.

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

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 : "); l = Convert.ToDouble(Console.ReadLine()); b = Convert.ToDouble(Console.ReadLine()); per_rect = 2 * (l + b); Console.WriteLine("Enter the radius of the circle : "); r = Convert.ToDouble(Console.ReadLine()); per_cir = 2 * PI * r; Console.WriteLine("Perimeter of Rectangle : {0}", per_rect); Console.WriteLine("Perimeter of Circle : {0}", per_cir); Console.Read(); } }

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

where PI = 22/7.

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.**

**Related Posts:**

- Apply for C# Internship
- Check Computer Science Books
- Apply for Computer Science Internship
- Check MCA Books
- Practice MCA MCQs