6 Semester Oop Lab Report 1
6 Semester Oop Lab Report 1
Write a program to implement a class called Circle that has private member variables for
radius.Include member functions to calculate the circle's area and circumference.*/
#include <iostream>
#include <cmath>
class Circle {
private:
double radius;
public:
Circle(double r) : radius(r) {}
double calculateArea() {
double calculateCircumference() {
};
int main() {
double radiusValue;
Circle myCircle(radiusValue);
cout << "Area of the circle: " << myCircle.calculateArea() << endl;
return 0;
}
/*B. Write a program to create a class called Person that has private member variables for name, age
and country. Implement member functions to set and get the values of these variables.*/
#include <iostream>
#include <string>
class Person {
private:
string name;
int age;
string country;
public:
name = n;
age = a;
country = c;
return name;
return age;
return country;
};
int main() {
Person person1;
person1.setPersonInfo("Shofikul ", 21, "Bangladesh");
return 0;
/*C. Write a program that defines a shape class with a constructor that gives value to width and
height.
The define two sub-classes triangle and rectangle, that calculate the area of the shape area (). In the
main,
define two variables a triangle and a rectangle and then call the area() function in this two
variables.*/
#include <iostream>
class Shape {
protected:
double width;
double height;
public:
};
public:
};
public:
};
int main() {
cout << "Area of the Triangle: " << myTriangle.area() << endl;
cout << "Area of the Rectangle: " << myRectangle.area() << endl;
return 0;
private
height, width, depth
public
declare 1 default constructor, 1 parameterized constructor and show() to display the values. Write
main()
function to declare an object to invoke all the constructor and show function for each object.*/
#include <iostream>
class Box {
private:
double height;
double width;
double depth;
public:
// Default constructor
// Parameterized constructor
cout << "Height: " << height << " | Width: " << width << " | Depth: " << depth << endl;
};
int main() {
Box defaultBox;
// Display values using the show() function
defaultBox.show();
paramBox.show();
return 0;
/* E. Write a program to print the area and perimeter of a triangle having sides of 3, 4 and 5 units by
creating
a class named 'Triangle' with the constructor having the three sides as its parameters. */
#include <iostream>
#include <cmath>
class Triangle {
private:
double side1;
double side2;
double side3;
public:
};
int main() {
return 0;
/* F. Write a program which will calculate the area of circle and rectangle using a base class shape and
#include <iostream>
#include <cmath>
class Shape {
public:
private:
double radius;
public:
Circle(double r) : radius(r) {}
};
private:
double length;
double width;
public:
};
int main() {
Circle myCircle(5.0);
return 0;