0% found this document useful (0 votes)
11 views2 pages

C++ Object-Oriented Programming Exercises

The document outlines a CAT Two assessment for a Diploma in ICT course at Machakos University, focusing on Object Oriented Programming in C++. It includes programming tasks in C++ such as creating classes, implementing polymorphism, function overloading, and dynamic memory allocation, as well as theoretical questions about OOP concepts. Students are required to demonstrate their understanding through coding exercises and explanations of key programming principles.

Uploaded by

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

C++ Object-Oriented Programming Exercises

The document outlines a CAT Two assessment for a Diploma in ICT course at Machakos University, focusing on Object Oriented Programming in C++. It includes programming tasks in C++ such as creating classes, implementing polymorphism, function overloading, and dynamic memory allocation, as well as theoretical questions about OOP concepts. Students are required to demonstrate their understanding through coding exercises and explanations of key programming principles.

Uploaded by

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

MACHAKOS UNIVERSITY

DICT DIPLOMA IN ICT MODULE TWO


CAT TWO
COURSE NAME: OBJECT ORIENTED PROGRAMMING
INSTRUCTIONS
Answer all questions

(1) Write a C++ program that will declare a class called calculate with two data members- the lower
and upper limit and a function member called set_value for initializing the lower and the upper
limit as 12 and 88 respectively, another function member called sum to calculate and return the
sum of all the even numbers from the lower limit to the upper limit. Declare an object called calc
and demonstrate how the two functions are called (7 marks)

(2) The following are the properties of a polymorphic base class used by students during a C++
Programming lesson:
- Marks of three subjects as data members;
- Function member to accept the marks in the three subjects
Write a C++ program that will implement five instances of a subclass of the base Class. The
program should determine and output the average marks in the three Subject through the use
of a member function (7 marks)
(3) Explain Three main differences between a class and a struct (3 marks)

(4) Discuss four conditions that necessitate function overloading (4 marks)


(5) Write a C++ program that will prompt the user to enter the date and year. The year Should not
be greater than 2020 and not less than 1900 otherwise an error message should be displayed.
The date includes day and month. The program should also check if the day entered is equal to
the number of days in that particular month, if not so the program should then display an error
message that the date is invalid otherwise it should display the date and year. (7 marks)
(6) List any three types of inheritance (3 marks)
(7) Describe the three types of constructors as applied in OOP (6 marks)
(8) Describe the term Dynamic memory allocation (2 marks)
(9) Define a class named ‘Bank Account’ to represent following members:
Data members :-
- Account Number
- Name of Depositor
- Account Type
- Balance Amount
Member functions:
- Initialize members
- Deposit Amount
- Withdraw Amount
- Display Balance
Write a C++ program to test the Bank Account class for 5 customers using an array. (7 marks)

(11) John is in the process of developing a program using OOP and want create his own defined
datatypes, as an expert outline to him three methods that can be used (3 marks)

(12) Distinguish between Function overloading and function overriding as used in


object-oriented programming. (4 marks)

(13) Using a class, develop a program that will accept a number through the keyboard,
The program should reverse the number and thereafter determine and output the
sum of all numbers. For example, if number is 153, the reverse will be 351 and
the sum will be 9 (3+5+1). If the sum is an odd number, then the program should
display a message indicating that its odd number, otherwise display a message
indicating it’s an even number. Use an overloaded operator and a while loop to
achieve this. (9 marks)

You might also like