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

Comp 103: Fundamentals Of Computer Programming Question Paper

Comp 103: Fundamentals Of Computer Programming 

Course:Bachelor Of Science In Computer Science

Institution: Chuka University question papers

Exam Year:2013






CHUKA

UNIVERSITY


UNIVERSITY EXAMINATIONS


FIRST YEAR EXAMINATIONS FOR THE AWARD OF DEGREE
OF BACHELOR OF SCIENCE IN COMPUTER SCIENCE

COMP 103: FUNDAMENTALS OF COMPUTER PROGRAMMING


STREAM: COMP SCI Y1S2 TIME: 2 HOURS

DAY/DATE: WEDNESDAY 7/8/2013 11.30 A.M – 1.30 P.M.

INSTRUCTIONS:

1. Answer question ONE and any other TWO questions
2. Marks are awarded for clear and concise answers
3. Note that only the first THREE attempted questions (Question 1 inclusive) will be marked

SECTION A – ATTEMPT ALL QUESTIONS IN THIS SECTION

QUESTION ONE (COMPULSORY) [30 MARKS]

(a) Differentiate between [4 marks]
(i) Flowchart and Pseudocode
(ii)Program documentation and program testing
(b) Give TWO differences between While…..Do and Repeat……Until [4 marks]
(c) List any THREE qualities of a good program [3 marks]
(d) List any two programming languages used in artificial intelligence [2 marks]
(e) Write a Pascal recursive function that can be used to compute n! [5 marks]
(f) Declare a one-dimensional array variable that can be used to store a list of student registration numbers for 50 students taking COMP 103 [3 marks]
(g) What is the output of the following code [6 marks]
For i: = 1 to 4 Do
For j: = 3 Down TO 1 Do
Begin

x:=i*j;
Write (x);
End;
(h) How is an array different from a record [3 marks]

SECTION B – ANSWER ANY TWO QUESTIONS FROM THIS SECTION
QUESTION TWO [20 MARKS]
(a) Study the program code below (written in pascal) and answer the questions that follow;
Program procFunc(input,output);
Var
x:integer;
Procedure P1(num1:integer;num2:integer);
Var
y:integer;
Begin
y:=num1;
num1:=num2;
Num2:=y;
Writeln(num1);
Writeln (num2);
End;
Function square (a: integer, b: integer): integer;
Begin
a:=a + b;
Square: =a*a;
End;
Begin
x:=5;
Writeln(square(x,6);
P1(x,10);
End.



(i) What is the output of this program [4 marks]
(ii) Identify one procedure call and one function call from the program. [2 marks]
(iii) List any one global variable and any one local variable from the program [2 marks]

(iv) List any TWO formal parameters and any TWO actual parameters from the program. [4 marks]

(b) Differentiate between a reserved word and an identifier [4 marks]
(c) Explain the meaning of the following Pascal expressions [4 marks]
(i) x:=x+4;
(ii) y: =x DIV 4;

QUESTION THREE [20 MARKS]
(a) Using a flow-chart differentiate between; If..Then..Else, While..DO and Repeat... Until control structures [9 marks]
(b) Write Pascal code that does the following;
(i) Declares an array variable that can be used to store integer values in a 4 by 5 matrix [3 marks]
(ii) Reads values entered from the keyboard and stores them in the array declared in b (i) above [3 marks]
(iii) Displays the contents of the elements in array declared in b(i) in form of a matrix on the screen. [3 marks]
(c) Why is it necessary to include comments in your program source code [2 marks]

QUESTION FOUR [20 MARKS]
(a) Write a program that will draw a box shape, wait a set time, then draw over and hide the shape using XORPut. [9 marks]
(b) Briefly describe what the procedure below does [6 Marks]
Procedure Greetuser (Username: string);
Begin
Text Background (2);
Textcolor(4);
ClrScr;


GoToXY(5,7);
Write (‘Hello ’,Username);
GoToXY(5,7);
Writeln(‘And how are you’);
End;
(c) Write a pascal function that accepts two integers and swaps them. [5 Marks]

QUESTION FIVE [20 MARKS]
(a) Using a loop, write a program that accepts Ten numbers and finds the
Largest. [8 Marks]

(b) Draw a flow-chart to input the length, width and depths of the deepest and shallowest ends of a rectangular swimming pool and calculate the volume required to fill this pool and display it in litres. [7 Marks]

(c) Give THREE Differences between a function and a procedure. [3 Marks]

(d) Write a pascal code that declares a record data type Date with three fields DD, MM, YY all of type integer. [2 Marks]



_______________________________________________________________________









More Question Papers


Popular Exams



Return to Question Papers