Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday 1 March 2017

Formula based program


Formula #4 (Perimeter and area of rectangle)

Enter length: 5
Enter breadth: 3
Perimeter of rectangle: 16
Area of rectangle: 15

The program for the formula is written in C# programming language and will accept number as length and breadth. Based on the formula it will find out the perimeter and area of rectangle.
 
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 Formula4     //perimeter and area of rectangle
    {
        static void Main(string[] args)
        {
            Console.Write("Enter length: ");
            double length = Convert.ToDouble(Console.ReadLine());
            Console.Write("Enter breadth: ");
            double breadth = Convert.ToDouble(Console.ReadLine());
            double area = 0.0, perimeter = 0.0;

            perimeter = 2 * (length + breadth);
            area = length * breadth;

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

            Console.ReadKey();
        }
    }
}

Output:
The input length here is 5 and breadth here is 3. So, based on the rectangle formula. The output is shown below:

Enter length: 5
Enter breadth: 3
Perimeter of rectangle: 16
Area of rectangle: 15
Press any key to continue . . .


For any query, comment us below.

Skip to Main Table – Formula based program

Previous – Formula based program #3


Click imagination hunt to read latest blogs.


Keep learning and sharing...

No comments:

Post a Comment

Featured post

Think that makes you rich and richer

 Napolean said: “You can think and grow rich, but if you can be brought up like most people with work and you won't starve, this wil...