Sys 4
Sys 4
Sys 4
//RA2311043010090
#include <iostream>
class Room {
private:
double length;
double width;
double height;
public:
// Constructor
Room(double l, double w, double h) : length(l), width(w), height(h) {}
int main() {
// Taking input for dimensions of the room
double length, width, height;
std::cout << "Enter the length of the room: ";
std::cin >> length;
std::cout << "Enter the width of the room: ";
std::cin >> width;
std::cout << "Enter the height of the room: ";
std::cin >> height;
return 0;
}
OUTPUT:
2. Write a C++ program for hierarchical inheritance to get square and cube of a
number.
Program code:
//RA2311043010090
#include <iostream>
// Base class
class Number {
protected:
int num;
public:
// Constructor
Number(int n) : num(n) {}
int main() {
int number;
std::cout << "Enter a number: ";
std::cin >> number;
return 0;
}
OUTPUT: