Connect with one of the following accounts


Please wait while we redirect...

Views: 100   

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

using System;

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

    double areaOfSquare = squareLength * squareLength;
    Console.WriteLine("Area of square is: " + areaOfSquare);

    double circumferenceOfSquare = 4 * squareLength;
    Console.WriteLine("Circumference of square is: " + circumferenceOfSquare);



Enter length of square:
Area of square is: 144
Circumference of square is: 48

On By

Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News