9. Write a program for finding area of different geometric shapes (circle, rectangle, cube). Use function overloading with type, order, sequence of arguments to find the area of shapes.

            // FUNCTION OVERLOADING -- AREAS of GEOMETRIC SHAPES


#include<iostream.h>
#include<iomanip.h>
 
float area(int);            // circle
float area(float);         // cube 
int area(int,int);          // rectangle

void main()
{
            int radius,length,breadth;
            float side;
            cout<<"Radius of Circle: ";
            cin>>radius;
            cout<<"Length of Side of Cube: ";
            cin>>side;
            cout<<"Length and Breadth of Rectangle: ";
            cin>>length>>breadth;
            cout<<"Area of Circle: "<<area(radius)<<"\n";
            cout<<"Area of Cube: "<<area(side)<<"\n";
            cout<<"Area of Rectangle: "<<area(length,breadth)<<"\n";
 
}
 
float area(int r)           // circle
{
            return (3.14159*r*r);
}
 
float area(float a)       // cube
{
            return (6*a*a);
}
 
int area(int l,int b)      // rectangle

{
            return (l*b);
}
Posted by Unknown On 02:00 2 comments

2 comments:

  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

Blog Archive

Contact Us


Name

E-mail *

Message *