using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Method_Ex_1
{
class Program
{
static void Main(string[] args)
{ //Get the value of radius from user
double radius;
Console.Write("Enter radius: ");
double.TryParse(Console.ReadLine(), out radius);
//call the AreaOfCircle method
double area = AreaOfCircle(radius);
//call the PerimeterOfCircle
double perimeter = PerimeterOfCircle(radius);
//Calling method is alike "a goto"
//The value of radius is passed (copied) to
//the parameter r (in the method definition)
Console.WriteLine("Area: {0}", area.ToString("f3"));
Console.WriteLine("Perimeter: {0}", perimeter.ToString("f3"));
Console.ReadKey();
}
static double AreaOfCircle(double r)
{
double a = Math.PI * r * r;
return a;
}
static double PerimeterOfCircle(double r)
{
double p = 2 * Math.PI * r;
return p;
}
}
}
No comments:
Post a Comment