Wednesday 23 April 2014

C# program to perimeter of rectangle and square

The perimeter is equal to the length of the boundary around the rectangle.

Perimeter of rectangle = 2l+2w
Perimeter of square = 4 * sides

SOURCE CODE :-


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

namespace perimeter
{
    class peri
    {
        public void perime()
        {
            double l_rectangle, b_rectangle;
            double p_rectangle;
            double sides;
            double p_square;
           
            Console.WriteLine("enter the value of length and breadth of rectangle");
            l_rectangle = double.Parse(Console.ReadLine());
            b_rectangle = double.Parse(Console.ReadLine());

            Console.WriteLine("Enter the sides of the square");
            sides = double.Parse(Console.ReadLine());
            p_rectangle = 2 * l_rectangle + 2 * b_rectangle;
            p_square = 4 * sides;
           
            Console.WriteLine("the perimeter of rectangle" + p_rectangle);
            Console.WriteLine("the perimeter of square" + p_square);

        }
       
    }
   
    class Program
    {
        static void Main(string[] args)
        {
            peri b = new peri();
            b.perime();
        }
    }
}



OUTPUT :-

enter the value of length and breadth of rectangle
3
3
Enter the sides of the square
5
the perimeter of rectangle 12
the perimeter of square 16


No comments:
Write comments

Featured post

List of Universities in Karnataka offering M.Sc Computer Science

The post-graduate programme in Computer Science (M.Sc Computer Science) contains two academic years duration and having a four semesters....

Popular Posts

Copyright @ 2011-2022