0% found this document useful (0 votes)
3 views1 page

Computer Programming Assignment Unit-II

The document outlines a computer programming assignment consisting of ten tasks focused on object-oriented programming concepts. Tasks include creating classes for Employee, Rectangle, ShapeCalculator, and others, implementing constructors, friend functions, and dynamic memory allocation. The assignment emphasizes practical implementation of class attributes, member functions, and data structures in programming.

Uploaded by

pass69899
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Computer Programming Assignment Unit-II

The document outlines a computer programming assignment consisting of ten tasks focused on object-oriented programming concepts. Tasks include creating classes for Employee, Rectangle, ShapeCalculator, and others, implementing constructors, friend functions, and dynamic memory allocation. The assignment emphasizes practical implementation of class attributes, member functions, and data structures in programming.

Uploaded by

pass69899
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computer Programming Assignment

Module 2:

[Link] a class Employee with attributes id, name, and salary. Write a program to create
multiple Employee objects and display their details.

2. Create a Rectangle class with length and width, include a default and parameterized
constructor, and write a program to calculate and print the area of two rectangle objects.

3. Implement a ShapeCalculator class that overloads the area() function to calculate the area
of a circle, rectangle, and triangle using appropriate dimensions.

4. Create two classes ClassA and ClassB, each with a private integer member. Write a friend
function sum() that accesses the private members of both classes and returns their sum.

5. Design a Student class with dynamic memory allocation for the student's name. Write a
program that accepts details of students, calculates their average marks, and displays the result
using a member function.

6. Define a structure named Student that contains the following members: name (string), age
(int), and grade (float). Write a function to initialize a Student object and print its details.

7. Create a structure called Book with members title, author, and price. Write a function that
takes a Book object as an argument and displays its details. Demonstrate accessing the
structure members in your main function.

8. Implement a class called Circle with a private member variable for the radius. Create member
functions to calculate the area and circumference of the circle. Write a main function to create
an instance of Circle, set its radius, and call the member functions.

9. Define two classes, Box and VolumeCalculator. The Box class has private attributes for
length, width, and height. Implement a friend function in the VolumeCalculator class that
calculates and returns the volume of a given box object.

10. Create two classes: Employee and Department. Make the Department class a friend of the
Employee class so it can access private members like salary. Write methods in both classes
to demonstrate this access in action.

You might also like