Class and Object Source code

This code is written by sagar dhakal.

for the educational purpose.....




 #include <iostream>


using namespace std;

class box

{

private:

    float l,b,area;

public:

    void readdata()

    {

        cout<<"\t\t\t*****************************";

        cout<<"\n\t\t\t\tWELCOME BY THE SAGAR DHAKAL\n\t\t\t_____________________________";

        cout<<"\n\n\t\tTo find Area of Square and rectangle\n\n\t1.Enter the value of length\n---->";

        cin>>l;

        cout<<"\n\t2.Enter the value of breadth\n---->";

        cin>>b;

    }

    void displayarea()

    {

    area=l*b;

    cout<<"The area of the following object is:\n\t\t\t\t"<<area;

    }

};

int main()

{

    box b1;

    b1.readdata();

    b1.displayarea();


    cout << "\n\t\tThank you!" << endl;

    return 0;

}


No comments:

Post a Comment

How to I fix Errors on Messenger ?

Fix the 'Unfortunately, Facebook Messenger has stopped' error Open Settings.  Select the Apps or Apps & notifications option.  T...

Contact form

Name

Email *

Message *

loading...