Formula #3 (Perimeter and area of semi-circle)
Enter radius: 5
Perimeter of semi-circle:
15.707963267949
Area of semi-circle: 39.2699081698724
The program for the formula is written
in C# programming language and will accept a number as radius. Based
on the formula it will find out the perimeter and area of semi-circle.
|
Formula based program |
Note:
If you are new to C# and Console Application. Try to code First C#
Program
Let’s find out a simple and easy way
to code these formula.
Practical Implementation:
using System;
namespace patternProblem.Formula
{
class Formula3 //area and perimeter of semi-circle
{
static void Main(string[] args)
{
Console.Write("Enter radius: ");
double radius = Convert.ToDouble(Console.ReadLine());
double area = 0.0, perimeter = 0.0;
perimeter = Math.PI * radius;
area = (Math.PI * (Math.Pow(radius, 2)) / 2);
Console.WriteLine("Perimeter of semi-circle: {0}", perimeter);
Console.WriteLine("Area of semi-circle: {0}", area);
Console.ReadKey();
}
}
}
Output:
The input radius
here is 7. So, based on the semi-circle formula. The output is shown below:
Enter radius: 7
Perimeter of semi-circle: 21.9911485751286
Area of semi-circle: 76.9690200129499
Press any key to continue . . .
For any
query, comment us below.
Keep learning and sharing...