CLASSES WITH PRIMITIVE DATA MEMBERS


SOURCE CODE:
#include<iostream.h>
#include<conio.h>
#define pi 3.14
class AREA
{
 int area1,area2;
 public:
     void circle(int r);
     void rectangle(int l,int b);
};
void AREA::circle(int r)
{
 area1=pi*r*r;
 cout<<"AREA OF THE CIRCLE : "<<area1;
}
void AREA::rectangle(int l,int b)
{
 area2=l*b;
 cout<<"AREA OF THE RECTANGLE : "<<area2;
}
void main()
{
 int r,l,b;
 clrscr();
 AREA JJ;
 cout<<"\nEnter the radius of the circle : ";
 cin>>r;
 JJ.circle(r);
 cout<<"\n\nEnter the length & breadth of the rectangle : ";
 cin>>l>>b;
 JJ.rectangle(l,b);
 getch();
}

OUTPUT :

Enter the radius of the circle :  7

AREA OF THE CIRCLE :  153

Enter the length & breadth of the rectangle :  15   7

AREA OF THE RECTANGLE :  105
Previous
Next Post »

Still not found what you are looking for? Try again here.