Formula based program

Formula #8 (Perimeter and area of parallelogram)

Enter length of side: 5
Enter height: 6
Perimeter of parallelogram: 22
Area of parallelogram: 30

The program for the formula is written in C# programming language and will accept a number as length of side and height of side. Based on the formula it will find out the perimeter and area of parallelogram.
 
Formula based program

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 Formula8     //perimeter and area of parallelogram
    {
        static void Main(string[] args)
        {
            Console.Write("Enter length of side: ");
            double sideLength = Convert.ToDouble(Console.ReadLine());
            Console.Write("Enter height: ");
            double height = Convert.ToDouble(Console.ReadLine());
            double area = 0.0, perimeter = 0.0;

            perimeter = 2 * (sideLength + height);
            area = sideLength * height;

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

            Console.ReadKey();
        }
    }
}

Output:
The input length of side here is 5 and height is 6. So, based on the parallelogram formula. The output is shown below:

Enter length of side: 5
Enter height: 6
Perimeter of parallelogram: 22
Area of parallelogram: 30


For any query, comment us below.

Skip to Main Table – Formula based program

Previous – Formula based program #7


Click imagination hunt to read latest blogs.


Keep learning and sharing...

Comments

Popular posts from this blog

SSC CGL 2016 Tier-1 Marks / Result

DATA TYPES IN C#

Pattern printing program

IS STRING MUTABLE OR IMMUTABLE IN .NET?

Top Mutual Funds