pgm1

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> using namespace std; class Box { private: float length; float breadth; float height; public: // Member functions to set values of length, breadth, and height void setLength(float l) { length = l; } void setBreadth(float b) { breadth = b; } void setHeight(float h) { height = h; } // Function to compute the volume of the box float compVolume() { return length * breadth * height; } }; int main() { // Declare pointers to Box class Box* box1 = new Box(); // Pointer for first Box object Box* box2 = new Box(); // Pointer for second Box object // Set dimensions for the first box box1->setLength(5.0); box1->setBreadth(3.0); box1->setHeight(2.0); // Set dimensions for the second box box2->setLength(7.0); box2->setBreadth(4.0); box2->setHeight(3.0); // Calculate and display the volume of the first box cout << "Volume of Box 1: " << box1->compVolume() << endl; // Calculate and display the volume of the second box cout << "Volume of Box 2: " << box2->compVolume() << endl; return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines