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

Mock Exam Dec 2014

Uploaded by

Elma
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)
16 views

Mock Exam Dec 2014

Uploaded by

Elma
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/ 4

Ministry of Secondary Education Republic of Cameroon

Progressive Comprehensive High School Peace – Work – Fatherland


PCHS Mankon – Bamenda School Year 2014/2015
Department of Computer Studies

SPECIAL MOCK 1 GCE EXAMINATION

December 2014 ADVANCED LEVEL


Subject Code/Title 795 - Computer Science
Paper N° Paper 3 Practical
Examiner DZEUGANG Placide

Time allowed: Two hours

Carry out ALL the tasks given. For your guidance, the approximate mark for each
part of a task is indicated in brackets.

Great importance is attached to the accuracy, layout and labeling of diagram and
computer-generated outputs.

You are reminded of the necessity for good English and orderly presentation of
your answers.

Record in the booklet provided any information requested or that you believe
would make it easier to understand how you carried out task and answered
questions

Where an imperative programming language is required to write program code,


Only C programming language should be used.

If need be, supervisors will assist you in recording details of intermediate work
carried out on the computer

Paper 3 Practical Computer Science Page 1 of 4


Special Mock 1 GCE Examination December 2014

INSTRUCTIONS
A folder should be created on the desktop carrying your name. All of your files should be saved
in that folder. Only the extension .c is accepted for any c program file and .docx for any word
processor document.

TASK A: Understanding of a program -----------------------------------[15 marks]


The program in appendix 1 consists of reading the marks of five students, calculate and display
the number of students who passed the test.

1. Type faithfully the program, save it as TaskA (make sure that your extension is .c). Compile
it, and make sure it contains no error. (4 mks)
2. Run the program using the following data: 12 4 11 18 9, capture the screen and paste it in a
blank word document to be saved as outputA1 (2 mks)
3. In your answer booklet copy and complete the following able (3 mks)
Variable Data type Its role in the program
k integer Represent the counter of values in the for loop
… … …
4. Justify why “%f” is used in line 10 instead of “%d” an in lines 9 and 16 (2 mks)
5. Explain the meaning of line 13 of the program and give another way of writing it. (2 mks)
6. What is the role of the instruction “#include<stdio.h>”? (2 mks)
(NB: to capture an active screen on windows press ALT+PRTSCR and paste it in the
concerned word document)

TASK B: Modification of a program ------------------------------------[20 marks]


Modify the program successively as indicated below. Each modification should be done on the
initial program TaskA, and saved successively as TaskB1, TaskB2, … and for each case, the
program should be executed using the data 12 4 11 18 9 by default, and the execution screen
captured and paste successively in a word document to be save as outputB.

1- Modify the program TaskA to receive 8 maks instead of 5 and save it as TaskB1. Use the
following data for the execution 12 4 11 18 9 6 14 10 (2 mks)
2- Modify the program TaskA to display the number of people who failed the test instead the
number who passed. Save it as TaskB2 (2 mks)
3- Rewrite the program TaskA using a while loop instead of the for loop and save it as TaskB3
(no execution is needed for this question ) (3 mks)
4- Modify the program TaskA to calculate and display the sum of all the passed marks entered
and save it as TaskB4 (3 mks)

Paper 3 Practical Computer Science Page 2 of 4


Special Mock 1 GCE Examination December 2014

5- Modify the program TaskA to calculate and display the sum of all the marks entered and save
it as TaskB5 (3 mks)
6- Modify the program TaskA to calculate and display the average of the marks entered and
save it as TaskB6 (3 mks)
7- Modify the program TaskA to prompt the user for the number of marks to enter. Use the
following data for input: 6 12 4 11 18 9 10 The expected output is shown in the appendix 2
(4 mks)

TASKC: Creation of a program -------------------------------------------[15 marks]


A quadratic equation consists of an equation of the type ax² + bx + c = 0. Solving a quadratic
equation consists of the following algorithm:
- Reading the coefficients a, b and c (supposed to be real numbers)
- Calculate the discriminant using the formula D = b² - 4ac
- Test the discriminant
 If it is negative, display no solution
 If it is equal to 0 then the equation has one solution x1 = -b/(2a)
 If it is positive, then the equation has two solutions 𝒙𝟏 = [− 𝒃 + √𝑫]/ (𝟐 𝒂)
and 𝒙𝟐 = [− 𝒃 + √𝑫]/ (𝟐 𝒂)
To calculate the square root of a number, include the library <math.h> and use the predefined
function sqrt(). (example: x = sqrt(9) assigns 3 to the variable x)
Write a c program that calculate and display the discriminant and the eventual solutions of a
quadratic equation, save it as TaskC. Use the program to solve the following equations
a) 2x 2 + 5x - 7 = 0
b) x 2 - 6 x + 9 = 0
c) x 2 - 4 x + 13 = 0
For each case capture the screen and paste it in a word document to be saved as outputC. An
example of expected output is given in the appendix 3

Paper 3 Practical Computer Science Page 3 of 4


Special Mock 1 GCE Examination December 2014

APPENDIX 1: Progrm to analyse marks APPENDIX 2: Example of output for Task B question 7
1 #include<stdio.h>
2
3 int main()
4 {
5 float mark;
6 int k, pass=0;
7 for(k=1;k<=5; k++)
8 {
9 printf("Enter mark for student %d: ", k);
10 scanf("%f", &mark);
11 if(mark>=10)
12 {
13 pass++;
14 }
15 }
16 printf ("%d people passed the test", pass);
17 return 0; APPENDIX 3: Example of output for Task C
18 }

Paper 3 Practical Computer Science Page 4 of 4

You might also like