Saturday 16 April 2016

WAP to Overload the function area() when passed 1 argument it will calculate an area of Circle ,when 2 argument area of Rectangle ,when 3 argument area of Cuboid .

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

namespace ConsoleApplication17
{
    class First
    {
       public void prindata(double r)
        {
            double area;
            area = 3.14 * r * r;
            Console.WriteLine("Circle Area : " + area);
        }
       public void printdata(int l, int b)
        {
            long area;
          area = l*b;
            Console.WriteLine("Rectangle Area : " + area);
        }
       public void printdata(long l, long b, long h)
       {
           long area;
           area = l*b*h;
           Console.WriteLine("Cuboid Area : " + area);
       }
    }
    class Program
    {
        static void Main(string[] args)
        {
            First a= new First();
            a.prindata(10);
            a.printdata(5,2);
            a.printdata(5, 2, 5);
            Console.ReadKey();
        }
    }
}

No comments:

Post a Comment