C# - Calculate the Perimeter of a Circle

Here, we are going to learn how to calculate the perimeter of Circle in C#? By Nidhi Last updated : April 15, 2023

Perimeter of Circle Formula

Here we will calculate the perimeter of the Circle using the below formula, It is also known as circumferences of the circle.

parimeter = (float)(2 * Math.PI * radius);

C# program to calculate the perimeter of Circle

The source code to calculate the perimeter of the Circle is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.

//Program to calculate the perimeter of Circle in C#

using System;

class Circle
{
    public static int Main()
    {
        float radius    = 0.0F;
        float parimeter = 0.0F;
        
        Console.Write("Enter the radius: ");
        radius = float.Parse(Console.ReadLine());

        parimeter = (float)(2 * Math.PI * radius);
        Console.WriteLine("Perimeter of Circle: "+parimeter);

        return 0;
    }
}

Output

Enter the radius: 7
Perimeter of Circle: 43.9823
Press any key to continue . . .

Explanation

Here, we created a class Circle that contains a method Main(). The Main() method is the entry point for the program. Here we read the value of the radius and calculate the perimeter of the Circle using the below formula, and then print the result on the console screen.

parimeter = (float)(2 * Math.PI * radius);

C# Basic Programs »


Related Programs



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.