0% found this document useful (0 votes)
12 views

Operator

The document contains code for a C++ program that defines a shape class with three area methods that can calculate the area of a square, circle, and rectangle. The main function creates a shape object, gets user input for the dimensions, and calls the appropriate area method to output the calculated area.

Uploaded by

mithunmp2004
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Operator

The document contains code for a C++ program that defines a shape class with three area methods that can calculate the area of a square, circle, and rectangle. The main function creates a shape object, gets user input for the dimensions, and calls the appropriate area method to output the calculated area.

Uploaded by

mithunmp2004
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<iostream.

h>
#include<conio.h>
class shape
{
public:
void area(int s)
{
int a;
a=s*s;
cout<<"\n area of square is"<<a;
}
void area(double r)
{
double a;
a=3.14*r*r;
cout<<"\n area of circle is"<<a;
}
void area(int l,int b)
{
int a;
a=l*b;
cout<<"\n area of rectangle is"<<a;
}
};
int main()
{
shape ob;
int s,l,b;
double r;
cout<<"\n enter the side of square";
cin>>s;
cout<<"\n enter the radius of circle";
cin>>r;
cout<<"\n enter the length and breadth of rectangle";
cin>>l>>b;
ob.area(s);
ob.area(r);
ob.area(l,b);
getch();
return 0;
}

You might also like