StudyLover
  • Home
  • Study Zone
  • Profiles
  • Contact us
  • Sign in
StudyLover 13. 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.
Download
  1. C++ Programs list
12. Program to design a class representing complex numbers and perform addition and multiplication using operator overloading. : 14. Program to process a shopping list for a departmental store using a class. The list includes details such as code number and price of each item, and operations like adding, deleting items, and printing the total value of an order.
C++ Programs list

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.

  1. #include <iostream.h>

  2. #include<conio.h>

  3. class Cube {

  4. public:

  5.     int length, breadth, height;

  6.  

  7.     // Function to accept details

  8.     void inputDetails() {

  9.         cout << "Enter length, breadth, and height: ";

  10.         cin >> length >> breadth >> height;

  11.     }

  12.  

  13.     // Function to calculate volume

  14.     int calculateVolume() {

  15.         return length * breadth * height;

  16.     }

  17.  

  18.     // Function to display details

  19.     void displayDetails() {

  20.         cout << "Length: " << length << endl;

  21.         cout << "Breadth: " << breadth << endl;

  22.         cout << "Height: " << height << endl;

  23.         cout << "Volume: " << calculateVolume() << endl;

  24.     }

  25. };

  26.  

  27. int main() {

  28.     Cube cube1;

  29.  

  30.     cube1.inputDetails();

  31.     cube1.displayDetails();

  32.     getch();

  33.     return 0;

  34. }

12. Program to design a class representing complex numbers and perform addition and multiplication using operator overloading. 14. Program to process a shopping list for a departmental store using a class. The list includes details such as code number and price of each item, and operations like adding, deleting items, and printing the total value of an order.
Our Products & Services
  • Home
Connect with us
  • Contact us
  • +91 82955 87844
  • Rk6yadav@gmail.com

StudyLover - About us

The Best knowledge for Best people.

Copyright © StudyLover
Powered by Odoo - Create a free website