0% found this document useful (0 votes)
13 views

Cit 2210 Computer Programming II

The document contains a past exam paper for a Computer Programming II exam. It consists of 4 questions testing knowledge of programming concepts and features in C++ such as algorithms, variables, data types, functions, classes, inheritance and polymorphism.

Uploaded by

bodhiambo943
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)
13 views

Cit 2210 Computer Programming II

The document contains a past exam paper for a Computer Programming II exam. It consists of 4 questions testing knowledge of programming concepts and features in C++ such as algorithms, variables, data types, functions, classes, inheritance and polymorphism.

Uploaded by

bodhiambo943
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

W1-2-60-1-6

JOMO KENYATTA UNIVERSITY OF AGRICULTURE AND


TECHNOLOGY
UNIVERSITY EXAMINATIONS 2017/2018
EXAMINATIONS FOR THE DEGREE OF BACHELOR OF SCIENCE IN GEOSPATIAL
INFORMATION SYSTEMS
CIT 2210: COMPUTER PROGRAMMING II
DATE: JANUARY 2018 TIME: 2 HOURS
INSTRUCTIONS: ANSWER QUESTION ONE AND ANY OTHER TWO
QUESTIONS

QUESTION ONE

a) Define the following terms (3 marks)

1) Algorithm
2) Program
3) Syntax

b) Differentiate between structured and object oriented programming


(2 marks)

c) Describe at least three qualities of a good algorithm (3 marks)

d) Outline three rules of declaring a variable (3 marks)

e) Explain why it is important to comment on a program (2 marks)

f) What will be the output of the following program (6 marks)

# include <iostream>
using namespace std;
int main()
{
(out << “Enter The Size Of Array:”;
int size;
(in>>size;
int array [size], key, i;
//Taking Input in array
For (int j=O; j<size; j(++)
{
Cout << “Enter”<<j<< “Element:”;
Cin>>array[j];
}
//Your Entered Array is
for (int a=0; a<size; a++)
Cout<< “array [“<<a<<”]=”;
Cout<<array [a]<<end i;
}
Cout<< “Enter key To search in Array”;
Cin>>key;
For (i=0, T<size ;T++)
{
If (key ==array [i])
{
Cout << “key Found At Index Number:
“<<i<<end1;
break;
}
}
If (I !=size)
{
Cout << “KEY FOUND at index:” <<I;
}
else {
Cout<< “KEY NOT FOUND in array”;
}
Return O;
}

g) State the uses of the following features in C++

1) End | (3 marks)
2) Cin >>
3) \t

h) List and explain the input and output operations in C++ (4 marks)

i) Outline any four rules of naming variable in programming (4 marks)

QUESTION TWO

a) Differentiate between the following operations; (6 marks)

1) / and %
2) = and ==
3) $$ and //

b) List down and describe the main C++ data types (4 marks)

c) Write a C++ program for an area of a building with functions (6 marks)


d) Distinguish between single line and multiline comments (4 marks)

QUESTION THREE

a) Explain the following terms (6 marks)

1) Inheritance
2) Single inheritance
3) Multiple inheritance

b) Write a C++ program to implement single inheritance with public access


specific (5 marks)

c) Explain how object oriented programming languages can be used to


implement abstract data types (4 marks)

d) Using a suitable C++ program show how an array can be used to display
the sum and average of ten numbers entered by the user (5 marks)

QUESTION FOUR

a) Differentiate between class and structure. With an example explain the


syntax for defining a class in C++ programming (6 marks)

b) Define compile time polymorphism, and provide a code fragment that


implements this concept in C++ (5 marks)

c) With an example, explain the order of invocation of constructors and


destructors in multiple inheritances (4 marks)

d) Can a class have virtual destructors? Explain your answer with an


example in C++ programming (5 marks)

You might also like