This program defines a cuboid class with three public member variables representing the length, breadth, and height of a cuboid. It then creates two cuboid objects, Box1 and Box2, and sets the values of their member variables. Finally, it calculates and prints the volume of each box.
This is a simple program that demonstrates how to define a class and create objects of that class. However, it does not include any member functions or methods that perform operations on the cuboid objects, so it is limited in what it can do.
#include<iostream> using namespace std; class cuboid { public: float length; float breadth; float height; }; int main() { cuboid Box1; cuboid Box2; float volume = 0.0; Box1.height = 5.0; Box1.length = 6.0; Box1.breadth = 7.0; Box2.height = 10.0; Box2.length = 12.0; Box2.breadth = 13.0; volume=Box1.height*Box1.length*Box1.breadth; cout<<"\nVolume of Box1 : "<<volume<<endl; volume=Box2.height*Box2.length*Box2.breadth; cout<<"\nVolume of Box2 : "<<volume<<endl; return 0; }To download raw file Click Here
Volume of Box1 : 210 Volume of Box2 : 1560
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions