   ## Monday, 27 February 2017

### Formula based program

Formula #2 (Perimeter and area of circle)

Perimeter of circle: 31.4159265358979
Area of circle: 78.5398163397448

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 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 Formula2     //area and perimeter of circle
{
static void Main(string[] args)
{
double area = 0.0, perimeter=0.0;

perimeter = 2* Math.PI * radius;
area = Math.PI * (Math.Pow(radius, 2));

Console.WriteLine("Perimeter of circle: {0}", perimeter);
Console.WriteLine("Area of circle: {0}", area);

}
}
}

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

Perimeter of circle: 43.9822971502571
Area of circle: 153.9380400259
Press any key to continue . . .

For any query, comment us below.

Previous – Formula based program #1

Click imagination hunt to read latest blogs.

Keep learning and sharing... 