#include <iostream>
using namespace std;
class shape
{
public:
void area(int side) {
cout << "area of square:" <<side*side << endl;
}
void area(float radius ) {
cout << "area of circle: " << 3.14*radius*radius << endl;
}
void area(int base,int height) {
cout << "area of triangle: " <<0.5*base*height << endl;
}
void area(float length,float breadth) {
cout << "area of rectangle: " << breadth*length << endl;
}
};
int main()
{
shape square;
/*shape circle;
shape triangle;
shape rectangle;*/
int side,base,height;
float radius,length,breadth;
cout<<"square:\n"<<"side:";
cin>>side;
square.area(side);
cout<<"circle:\n"<<"radius:";
cin>>radius;
square.area(radius);
cout<<"triangle:\n"<<"base and height :";
cin>>base>>height;
square.area(base,height);
cout<<"rectangle:\n"<<"length and breadth:";
cin>>length>>breadth;
square.area(length,breadth);
return 0;
}
No comments:
Post a Comment