Using variables and literals to calculate some circle area - CSharp Language Basics

CSharp examples for Language Basics:Variable

Description

Using variables and literals to calculate some circle area

Demo Code


using System;/*from ww  w .  j  a  v  a2 s  .c o m*/

class variables
{
    public static void Main()
    {
        int radius = 4;
        const double PI = 3.1459;
        double circum, area;

        area = PI * radius * radius;
        circum = 2 * PI * radius;

        Console.WriteLine("Radius = {0}, PI = {1}", radius, PI );
        Console.WriteLine("The area is {0}", area);
        Console.WriteLine("The circumfrance is {0}", circum);
    }
}

Result


Related Tutorials