C# program to calculate rectangle area and circumference


Following program shows you how to calculate rectangle area and circumference.
This program gets rectangle length and width from user and calculates area and circumference and prints them using following formulas
Area = length X width
Circumference = 2 X length + 2 X width

using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine("Enter length of rectangle:");
    double rectangleLength = Convert.ToDouble(Console.ReadLine());

    Console.WriteLine("Enter width of rectangle:");
    double rectangleWidth = Convert.ToDouble(Console.ReadLine());

    double areaOfRectangle = rectangleLength * rectangleWidth ;
    Console.WriteLine("Area of rectangle is: " + areaOfRectangle);

    double circumferenceOfRectangle = 2 * (rectangleLength) + 2 * (rectangleWidth);
    Console.WriteLine("Circumference of rectangle is: " + circumferenceOfRectangle);

  }
}

Output:

Enter length of rectangle:
 35
Enter width of rectangle:
 55
Area of rectangle is: 1925
Circumference of rectangle is: 180