Get premium membership and access revision papers, questions with answers as well as video lessons.

Csc121: Programming And Problem- Solving Question Paper

Csc121: Programming And Problem- Solving 

Course:Bachelor Of Science In Computer Science

Institution: South Eastern Kenya University question papers

Exam Year:2017



SOUTH EASTERN KENYA UNIVERSITY
UNIVERSITY EXAMINATIONS 2016/2017

SECOND SEMESTER EXAMINATION FOR THE DEGREE OF BACHELOR OF SCIENCE
IN COMPUTER SCIENCE


CSC121: PROGRAMMING AND PROBLEM- SOLVING

DATE: 11TH APRIL, 2017 TIME: 1.30 -3.30 PM


INSTRUCTIONS TO CANDIDATES

a) Answer ALL questions from section A(Compulsory)
b) Answer ANY TWO questions from section B


SECTION A (30 Marks) - Compulsory

Question One
a) Define the following terms: [2 Marks]
i) Algorithm
ii) Function overloading
b) Differentiate between pass by value and pass by reference as used in C++. [2 Marks]
c) Outline two advantages of using high-level language over low- level language. [2 Marks]

d i) Analyze the code fragment shown below, and determine the output generated after its execution.[2 Marks]

int found = 0, count = 5; if (!found || count == 0) cout << "Hatari" << endl;

cout << "count = " << count << endl;


ii) Justify your answer in (i) above [1 Mark]


e i) Outline two rules for naming a variable. [2 Marks]

ii) With the help of an example in C++; explain the difference between local and global

variables. [3 Marks]

f) Explain the meaning of the following escape sequence characters. [2 Marks]

i)\a “”

ii)\n”“

g) Write a C++ program, using for control structure that would vertically display odd numbers between 0 and 60 in descending order. [4 Marks]


h i) Draw a flowchart for a program that can be used to classify people according to age. If a

person is more than 20 years, output “Adult” [3Marks]
ii) Write a C++ program code that will implement the flowchart drawn in h
(i) above. [3 Marks]

i) Write a program in C++ that prompts the user to enter the radius of a circle, then computes and

displays the area and circumference of the circle. [4 Marks]


SECTION B (40 Marks): ANSWER ANY TWO QUESTIONS
Question Two
a i) Define the term pointer. [1 Mark]
ii) With the aid of example, explain how to define pointer variables in C++. [4 Marks]
b) Describe the hierarchy of C++ data types. [6 Marks]

c) Write a C++ program that prompts the user to enter two numbers, then calculates and displays

the sum, product, difference, and modulus of those two numbers. [4 Marks]

d) Write a program in C++ that prompts the user to enter temperature in Fahrenheit, convert

temperature given in degrees Fahrenheit to Celsius and then display the output on the
screen.(hint: C = (F-32) * 5 / 9)[5 Marks]

Question Three
a) Outline four characteristics of a good computer program. [4 Marks]
b) Using examples, describe four categories of operators used in C++ language. [4 Marks]

c) Using a switch case, write a C++ program that prompts a user to enter student grade, the

program should then display the remark as indicated in the table below. [6 Marks]


GRADE REMARK
A DISTINCTION
B CREDIT
C CREDIT
D PASS
F FAIL
ANY OTHER INVALID GRADE


d) Write a C++ program that displays numbers that are divisible by nine between 1and 100.

[6 Marks]
Question Four
a) Explain the importance of stream classes in C++ programming. [3 Marks]
b) Study the code fragment shown below and answer the questions that follow.
int n, k = 5;
n = (100 % k ? k + 1 : k - 1);
cout << "n = " << n << " k = " << k << endl;

i) Construct a flowchart to depict the logic of the code fragment. [3 Marks]
ii) Determine the output generated when the following code fragment is executed. [2 Marks]
c) Functions play a very important role in any program.
i) Explain the term function . [2 Marks]
ii) Describe how to define and call a function. [4 Marks]

d) Write a C++ program that prompts the user to enter three numbers, then finds out and displays

the largest number of the three numbers entered. [6 Marks]
























More Question Papers


Popular Exams



Return to Question Papers