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

Write a C program that: 1. Accepts the total purchase amount, customer type, and season from the user. 2. Uses nested if-else statements to calculate and display the final amount after applying the discount.

Here is a C Program for Customer and Day Based Shop Management Program  #include <stdio.h> int main () {     char name [ 20 ];     ...

Contact form

Name

Email *

Message *

loading...