C#: Program to calculate area and perimeter of a circle

In this C# tutorial we "calculate area and perimeter of a circle" . Here we are taking four variables "r" for radius ,we assign our constant variable "pi" to 3.14, "ar" for area and "p" for perimeter of circle respectively. Now, lets get started!!

using System;
​class prg
{
 public static void Main(String []args)
 {
        double r,pi=3.14,ar,p;
        Console.WriteLine("Please enter radius of circle : ");
        r=Convert.ToInt32(Console.ReadLine());
        ar=pi*r*r;
        p=2*pi*r;
        Console.WriteLine(ar+"sq units" + " is area of circle with given radius");
        Console.WriteLine(p+"units" + " is perimeter of circle with given radius");

 }
}
SHARE

Raunak Hajela

Hi. I’m CEO/Founder of Kodestat. I’m Student, Geek, Web Designer, Developer, Blog Enthusiast and Player. Inspired to make things looks better. I like playing with codes plus I am marvel fan :-P You can check my design portfolio here. For consulation fell free to drop an email at raunakhajela@gmail.com.

  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment