Wednesday, 27 November 2013

C# Structure Area Of Rectangle Program-----|||||||||

Code:

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

namespace AreaOfRectangleUsingStructure
{
    class Program
    {
        struct Rectangle
        {
            int length;
            int breadth;
            Rectangle(int x, int y)
            {
                length = x;
                breadth = y;
            }
       //     int area()
        //    {
        //        return length * breadth;
//}

            public static void Main(string[] args)
            {
                Rectangle rect = new Rectangle();
                rect.length = 100;
                Console.WriteLine("\n The length of Rectangle" + "=" + rect.length);
                rect.breadth = 100;
                Console.WriteLine("\n The length of Rectangle" + "=" + rect.length);
                int area = rect.length * rect.breadth;
                Console.WriteLine("\nThe area of Rectangle is" + "=" + area);
                Console.ReadKey();
            }
        }
    }
}


Output:

No comments:

Post a Comment