   Tuesday, 28 February 2017

Formula based program

Formula #3 (Perimeter and area of semi-circle)

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.

Note: If you are new to C# and Console Application. Try to code First C# Program

Note: Read articles on how to use Loops and Conditions.

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)
{
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);

}
}
}

Output:
The input radius here is 7. So, based on the semi-circle formula. The output is shown below:

Perimeter of semi-circle: 21.9911485751286
Area of semi-circle: 76.9690200129499
Press any key to continue . . .

For any query, comment us below.

Skip to Main Table – Formula based program

Previous – Formula based program #2

Click imagination hunt to read latest blogs.

Keep learning and sharing... 