0% found this document useful (0 votes)
24 views5 pages

Data Structures in C++

This document is an examination paper for a Data Structures course at Kampala University, covering various topics in C++. It includes multiple-choice questions, short notes, programming tasks, and definitions related to C++ concepts and data structures. The exam is structured to assess students' understanding of programming fundamentals and their ability to write C++ code.

Uploaded by

prove143d
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)
24 views5 pages

Data Structures in C++

This document is an examination paper for a Data Structures course at Kampala University, covering various topics in C++. It includes multiple-choice questions, short notes, programming tasks, and definitions related to C++ concepts and data structures. The exam is structured to assess students' understanding of programming fundamentals and their ability to write C++ code.

Uploaded by

prove143d
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
You are on page 1/ 5

Kampala University

UNIVERSITY EXAMINATIONS

END OF SEMESTER EXAMINATIONS

AUGUST-DECEMBER, 2019

SCHOOL : COMPUTER SCIENCE AND INFORMATION TECHNOLOGY

PAPER : DATA STRUCTURES IN C++

CODE : BCSIT 3101

DURATION : 3 HOURS

DATE :

INSTRUCTIONS

 DO NOT OPEN THIS QUESTION PAPER UNTIL YOU ARE TOLD TO DO SO.

 Question one is compulsory.

 Attempt any other four questions.

 Each question carries 20 marks.

 Do not write anything on the question paper.


QUESTION ONE

For Questions 1-10, circle the most suitable answer from the available alternatives.
[2marks@]
1) Which of the following class allows to declare only one object of it?
a) Abstract class
b) Virtual class
c) Singleton class
d) Friend class

2) Which of the following is not a type of Constructor?


a) Friend constructor
b) Copy constructor
c) Default constructor
d) Parameterized constructor

3) Out of the following, which is not a member of the class?


a) Static function
b) Friend function
c) Constant function
d) Virtual function

4) *ptr++ is equivalent to:

a) ptr++
b) *ptr
c) ++*ptr
d) None of the above
5) Which concept allows you to reuse the written code?
a) Encapsulation
b) Abstraction
c) Inheritance
d) Polymorphism

6) Which of the following is an abstract data type?


a) int
b) float
c) class
d) string

7) What is the output of the following program

int a = 10;
void main()
{
int a = 20;
cout << a << ::a;
}
a. Syntax error
b. 10 20
c. 20 10
d. 20 20

8) Which of the following correctly declares an array?


a) int array[10];
b) int array;
c) array{10};
d) array array[10];

9) The output of this program is

int main () {

cout << "Hello World!"

return 0;

a) Hello World
b) Syntax error
c) 0
d) Hello World!

10) Which one of the following is not a fundamental data type in C++
a) float
b) string
c) int
d) wchar_t
QUESTION TWO

1) Write shorts Notes about the following (2 marks @)

i. Primitive data types


ii. Logical operators
iii. Syntax of a programing language
iv. Semantics of a programming language
v. Loops
vi. Constructors
vii. Destructors
viii. Polymorphism
ix. Overloading
x. Overriding

QUESTION THREE

a) Write a C++ program which declares two arrays of type int. let these arrays have names num1
and num2 and can store up to five integers. [5marks]
b) Initialize num1 with values 1, 2,3,4,5 and initialize num2 with values 6, 7, 8, 9, 10. [5marks]
c) Display the contents on the screen. [5marks]
d) Swap the contents of num1 with num2 and vise vasa. (5marks)

QUESTION FOUR

a) Define a function? Write down the syntax for defining a function, explain any two
types of functions. (6 marks)
b) Using a library function, write a program that will allow you enter a number of type
integer, and finds the square root of that exact number. (7 marks)
c) Write a program to add two integers and make a function add() to add and display the
sum in the main function. (7 marks)
QUESTION FIVE
a) Define a character Array? Write the Syntax, with appropriate example, to declare and
initialize it. (4 marks)
b) Write a program that accepts different numbers from 5 to 9 and finds their average.
(8 marks)
c) Write a program that will convert an integer pointer to an integer and vice-versa. (8
marks)

QUESTION SIX

a) Define Data Structures? Explain the different types of data structures in C++. (8 marks)
b) Define Data type, and differentiate between primitive and non-primitive data types. (6marks)
c) What is a Variable? What is the difference between an integral variable and a floating-point
variable? (6 marks)

QUESTION SEVEN

a) Define the following terms; (2 marks @)


i. Interior node of a tree
ii. Leaf of a tree
iii. Height of a tree
iv. Binary tree
v. Root of a tree

b) What are the different Binary tree traversal techniques? And list the tasks performed
while traversing a Binary tree? (10 marks)

GOOD LUCK!

You might also like