C# program to calculate the perimeter of Circle

Here, we are going to learn how to calculate the perimeter of Circle in C#?
Submitted by Nidhi, on October 11, 2020

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);

Program:

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);





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.