C# Program Calculating the Area of a Rectangle

C# Program Calculating the Area of a Rectangle

C# Program Calculating the Area of a Rectangle

Object: Let us consider a Rectangle object. It has attributes such as length and width. Depending upon the design, it may need ways for accepting the values of these attributes, calculating the area, and displaying details. C# Projects.

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lab1b
{
class Rectangle
{
public void mul(int length, int width)
{
Console.WriteLine(“Length = “+(length));
Console.WriteLine(“Width = “+(width));
Console.WriteLine(“Area of Rectangle = ” +(width * length));
}
}
class Program
{
static void Main(string[] args)
{
Rectangle obj= new Rectangle();
obj.mul(5,3);
Console.ReadKey();
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lab1b
{
    class Rectangle
    {
        public void mul(int length, int width)
        {
            Console.WriteLine("Length = "+(length));
            Console.WriteLine("Width = "+(width));
            Console.WriteLine("Area of Rectangle = " +(width * length));
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Rectangle obj= new Rectangle();
            obj.mul(5,3);
            Console.ReadKey();
        }
    }
}

Output:

C# Program Calculating the Area of a Rectangle

C++ projects for beginners with source code