Answer to Question #199051 in C++ for PRIYANKA K

Question #199051

calculate and display the area and volume of the room. program to illustrate the working of objects and class in C++ programming


1
Expert's answer
2021-05-26T13:49:24-0400


#include <iostream>


using namespace std;


class Room{
    private:
        int length;
        int width;
        int height;
        
    public:
        Room(int l,int w,int h){
            length=l;
            width=w;
            height=h;
        }
        void Area(){
            cout<<"\nThe Area of the room is "<<length*width;
        }
        void Volume(){
            cout<<"\nThe Volume of the room is "<<length*width*height;
        }
};


int main()
{
    Room r(34,56,78);
    r.Area();
    r.Volume();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog