How to calculate area of a circle in c#

April 29, 2013

How to calculate area of a circle in c#


Object


Write a program which takes radius of a circle and calculates the area in case the value entered by the user is non-zero positive integer. And it displays an error message otherwise.

Code

double area;
             int   radius;
         
            Console.WriteLine("\t\tFind The Area OF Circle\n");
            Console.Write("Enter The Radius : ");
          
                radius = int.Parse(Console.ReadLine());
                if (radius > 0)
                {
                area = 3.14 * radius * radius;
                Console.WriteLine("Area is  : " + area);
            }
            else
            {
                Console.WriteLine(".....error......");
            }





How to calculate area of a circle in c#

You Might Also Like

0 comments

Popular Posts

Like us on Facebook

Flickr Images