This simple program calculates the area of a rectangle.
Variables are defined in the first row. In the next lines, values are assigned to these variables.
In the last line we print the area of Rectangle to the screen.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | class Program { static void Main(string[] args) { int area, length, width; Console.Write("Please write the length of your rectangle: "); length = Convert.ToInt32(Console.ReadLine()); Console.Write("Please write the width of your rectangle: "); width = Convert.ToInt32(Console.ReadLine()); area = length * width; Console.WriteLine("The area of rectangle : {0}", area); Console.ReadKey(); } } |
Output:
Online Code: