In this C# tutorial we "calculate area and perimeter of a rectangle" . Here we are taking four variables "l" for length ,"b" for breadth, "ar" for area and "p" for perimeter of rectangle respectively. Now, lets get started!!
using System;
class prg
{
public static void Main(String []args)
{
float l,b,ar,p;
Console.WriteLine("Please enter length of rectangle : ");
l=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please enter breadth of rectangle : ");
b=Convert.ToInt32(Console.ReadLine());
ar=l*b;
p=2*(l+b);
Console.WriteLine(ar+"sq units" + " is your area");
Console.WriteLine(p+"units" + " is your perimeter");
}
}
0 comments:
Post a Comment