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"); } }
0 comments:
Post a Comment