Posted in All Posts, Semester 3

Sem 3 – OOCP Unit 1 Programs

OOCP – Object Oriented Concepts & Programming

Unit 1 – Introduction to OOP, Classes & Objects

1. Write a program to calculate the area of circle, rectangle and square using function overloading.
Download | View Code

2. Write a program to demonstrate the use of default arguments in function overloading.
Download | View Code

3. Write a program to demonstrate the use of returning a reference variable.
Download | View Code

4. Create a class student which stores the detail about roll no, name, marks of 5 subjects, i.e. science, Mathematics, English, C, C++. The class must have the following:
• Get function to accept value of the data members.
• Display function to display values of data members.
• Total function to add marks of all 5 subjects and store it in the data members named total.
Download | View Code

5. Create a function power() to raise a number m to power n.the function takes a double value for m and int value for n, and returns the result correctly. Use the default value of 2 for n to make the function calculate squares when this argument is omitted. Write a main that gets the values of m and n from the user to test the function.
Download | View Code

6. Write a basic program which shows the use of scope resolution operator.
Download | View Code

7. Write a C++ program to swap the value of private data members from 2 different classes.
Download | View Code

8. Write a program to illustrate the use of “this” pointer.
Download | View Code

9. An election is contested by five candidates. The candidates are numbered 1 to 5 and the voting is done by marking the candidate number on the ballot paper. Write a program to read the ballots and count the votes cast for each candidate using an array variable count. In case a number is read outside the range of 1 to 5, the ballot should be considered as a ‘spoilt ballot’ and the program should also count the number of spoilt ballots.
Download | View Code

10. Write a program to call member functions of class in the main
function using pointer to object and pointer to member function.
Download | View Code

Download All

I hope that you found this article to be helpful.
Please share your thoughts in the Comments Section.

If you liked this article, then please like our Facebook page and Subscribe our YouTube channel.

Suggested Reading

7 thoughts on “Sem 3 – OOCP Unit 1 Programs

Comment your thoughts