To find the perimeter of a square, just add up all the lengths of the sides.
The area of a square: To find the area of a square, multiply the lengths of two sides together. Another way to say this is to say “square the length of a side.
In this example, I’ll show how to calculate area and perimeter of rectangle in C#.
Source Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
static void Main(string[] args) { int s, area, perimeter; Console.Write("Side : "); s = Convert.ToInt32(Console.ReadLine()); area = 4*s; perimeter = s*s; Console.WriteLine("Area of Square : "+area); Console.WriteLine("Perimeter of Square : "+perimeter); Console.ReadKey(); } |
Output: