Q:

C# program to calculate the perimeter of Circle

belongs to collection: C# Basic Programs | basics

0

C# program to calculate the perimeter of Circle

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# Basic Programs | basics

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C# program to calculate the perimeter of Rectangle... >>
<< C# program to calculate the volume of Sphere...