C# Chapters

C# Program to Calculate Area and Circumference of a Circle.

Operators - C# Language Fundamentals
using System;

public class Program
{
    public static void Main()
    {
        Decimal Radius, Area, Diameter, Circumference, PI = (Decimal)3.14;
        
        Console.Write("Enter Radius of Circle : ");
        Radius = Convert.ToDecimal(Console.ReadLine());
        
        Area = PI * (Radius * Radius);
        Diameter = Radius * 2;
        Circumference = PI * Diameter;
        
        Console.Write("\n\nArea of Circle is : " + Area);
        Console.Write("\nDiameter of Circle is : " + Diameter);
        Console.Write("\nCircumference of Circle is : " + Circumference);
    }
}

Output :
Enter Radius of Circle : 10

Area of Circle is : 314 .00
Diameter of Circle is : 20
Circumference of Circle is : 62.80

Description :

Area of Circle = Π * R * R
Π = 3.14 (GREEK CAPITAL LETTER PI)
R = Radius of Circle

Circumference = Π x Diameter
Diameter = 2 x Radius


Leave a comment
Recent Comments
No Comments