Write a program for Member Function for each task

/*Member Function for each task */
#include<iostream>
using namespace std;

class Rectangle
{
    int l,b;
    public:
            void accept()
            {
                cout<<"\n\n Enter length and breadth: ";
                cin>>l>>b;
            }

            void area();
            void peri();
};
void Rectangle::area()
{
   cout<<"\n\n Area:"<<l*b;
}

void Rectangle::peri()
{
  cout<<"\n\n Perimeter: "<<2*(l+b);
}

int main()
{
   Rectangle r;

   r.accept();
   r.area();
   r.peri();

   return 0;
}

Previous
Next Post »