C#: Program to calculate area and perimeter of a rectangle

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");

 }
}
SHARE

Raunak Hajela

Hi. I’m CEO/Founder of Kodestat. I’m Student, Geek, Web Designer, Developer, Blog Enthusiast and Player. Inspired to make things looks better. I like playing with codes plus I am marvel fan :-P You can check my design portfolio here. For consulation fell free to drop an email at raunakhajela@gmail.com.

  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment