0% found this document useful (0 votes)
153 views3 pages

Mid Semester Exams C++ September 2023

This document contains a mid-semester assignment for a Higher Level Programming with C++ course, consisting of multiple choice and short answer questions testing knowledge of C++ concepts like data types, classes, objects, constructors, destructors, inheritance, polymorphism, and functions. Students are asked to answer all questions in Parts A and B, and choose two of the five questions in Part C to fully answer.

Uploaded by

richametwi
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)
153 views3 pages

Mid Semester Exams C++ September 2023

This document contains a mid-semester assignment for a Higher Level Programming with C++ course, consisting of multiple choice and short answer questions testing knowledge of C++ concepts like data types, classes, objects, constructors, destructors, inheritance, polymorphism, and functions. Students are asked to answer all questions in Parts A and B, and choose two of the five questions in Part C to fully answer.

Uploaded by

richametwi
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
You are on page 1/ 3

GHANA COMMUNICATION TECHNOLOGY UNIVERSITY

(GCTU)

FACULTY OF COMPUTING AND INFORMATION SYSTEMS

DEPARTMENT OF INFORMATION TECHNOLOGY

DIT level 100/ IS level 100

MID SEMESTER ASSIGNMENT

SEPTEMBER 2023

COURSE TITLE: HIGHER LEVEL PROGRAMMING WITH C++

TOTAL MARKS = 50

ANSWER ALL QUESTIONS IN PARTS (A & B )

AND ANY 2 FROM PART C


PART A (5 X 1 = 5 MARKS) ANSWER ALL

1. The most efficient data type for a variable that stores the letter C is the _______ data type
a) Character
b) Double
c) Float
d) Long Integer

2. A function that is called automatically each time an object is created is a(n)


a) Constructor
b) Destructor
c) Destroyer
d) Terminator

3. Files whose names end in .h are called …………………………… files


a) Handy
b) Header
c) Helper
d) Helping

4. A class D can be derived from a class C, which is derived from a class B, which is
derived from a class A
a) True
b) False

5. To hide a data member from the program, you must declare the data member in the
_______ section of the class
a) Conceal
b) Confidential
c) Hidden
d) Private

PART B ANSWER ALL (5 MARKS)


1. Is encapsulation and data hiding the same? Comment (2 marks)
2. Differentiate between an object and a class? (2 marks)
3. Friend functions can belong to more than one class. True or False? 1 MARK
PART C (2 X 20 = 40 MARKS) ANSWER ANY 2 QUESTIONS

1. A )Define and explain the use of constructors and destructors in C++. Provide an example of a
class with a constructor and a destructor. 10 marks
B) Write a C++ program to find the factorial of a non-negative integer using recursion 10
MARKS

2. A) Explain the concept of object-oriented programming (OOP) and how it is implemented


in C++. Provide an example of a class and an object in C++ (10MARKS )

B) Write a C++ program that uses a function to check if a given number is prime or not.
The program should ask the user to input a positive integer and then call the function to
check if it's a prime number or not. If the number is prime, the program should output
"The number is prime." If the number is not prime, the program should output "The
number is not prime."

3. A) Using functions create a c++ program that Prints Prime numbers between 1 to 100 (6
marks)
B) State 4 benefits of programming in the object oriented approach.(8 marks)
C) Demonstrate how friend functions are implemented(6marks)

4. A) Define compile time polymorphism, and provide a code fragment that implements
FUNCTION OVERLOADING as one of the types of this concept in C++. Explain the
implemented concept in detail(10 marks)

C) Define run-time polymorphism, and provide a code fragment that implements


VIRTUAL FUNCTIONS as one of the types this concept in C++. Explain the
implemented concept in detail (10 marks)

5. A) Discuss the concept of inheritance in C++. Provide an example of a base class and a
derived class with a clear explanation of how inheritance is achieved. Explain with example
codes, any 4 of the various types of inheritance supported in C ++. (20 marks)

You might also like