1. Program to create a class called `Cube` with data members `length`, `breadth`, and `height` and member functions to accept details, calculate the volume, and display the details.
#include <iostream.h>
#include<conio.h>
class Cube {
public:
int length, breadth, height;
// Function to accept details
void inputDetails() {
cout << "Enter length, breadth, and height: ";
cin >> length >> breadth >> height;
}
// Function to calculate volume
int calculateVolume() {
return length * breadth * height;
}
// Function to display details
void displayDetails() {
cout << "Length: " << length << endl;
cout << "Breadth: " << breadth << endl;
cout << "Height: " << height << endl;
cout << "Volume: " << calculateVolume() << endl;
}
};
int main() {
Cube cube1;
cube1.inputDetails();
cube1.displayDetails();
getch();
return 0;
}