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++ projects for beginners with source code
Pingback: C# Program that Subtracts two user defined numbers
Pingback: C# Program Create a class student with a data members name and calculate marks and percentage.
Pingback: C# program to count vowels in a string
Pingback: Write a C# program to create a static function factorial and calculate factorial of the number.
Pingback: Write a C# program that reads two arrays and checks whether they are equal.
Pingback: Develop a C# app that will determine the gross pay for each of three employees
Pingback: C# program that defines a class to represent a bank account which includes the following member
Pingback: Write a C# program to demonstrate the multiple inheritances
Pingback: C# Program that read array display the smallest integer and sort the array in ascending order by using Array.Sort method.
Pingback: Write a C# program of throwing an exception when dividing by zero condition occurs
Pingback: Implement bubble sort in C# the value of array given by the users
Pingback: Top 20 C# programs examples in 2021