2001 Ce Cs Paper Ibc C Version

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View 2001 Ce Cs Paper Ibc C Version as PDF for free.

More details

  • Words: 2,514
  • Pages: 12
2001-CE COMP STUD

Candidate Number

PAPER I (SECT B & C)

Centre Number HONG KONG EXAMINATION AND ASSESSMENT AUTHORITY HONG KONG CERTIFICATE OF EDUCATION EXAMINATION 2001

Seat Number

COMPUTER STUDIES PAPER 1 (SECTIONS B & C) Question-Answer Book 8:30 am – 10:30 am (2 hours) This paper must be answered in English

Marker’s Use Only Marker No.

Examiner’s Use Only Examiner No.

Q.6 Q.7 Instructions: 1.

Write your Candidate Number, Centre Number and Seat Number in the spaces provided.

2.

Answer all questions.

Q.8 Q.9 Q.10 Q.10

0

1

2

3

4

0

1

Total 3.

Write your answers in the spaces provided in this question-answer book.

4.

Supplementary answer sheets will be supplied upon request. Write your Candidate Number on each sheet and fasten them with string inside this book.

Checker’s Use Only Checker No. Total

2001-CE-COMP STUD 1B & C-1 (C Version)

2

3

4

Section B (40 marks) Answer ALL questions in this section. 6.

Mr. Lee is a Mathematics teacher. He uses a text file to record the scores obtained by his students in two tests. In the text file, each line contains the data of one student. The number of lines in the file is not fixed. There are three data fields in each line and each data field is separated by a blank character. The format of each line is as follows: 4-digit Student Number Score of Test 1 Score of Test 2 Below are the data files for the years 1999 and 2000: DATA1999.TXT DATA2000.TXT 5760 73 93 4731 47 86 8288 18 25 4667 52 66 7654 45 10 3267 99 72 0157 99 98 1249 17 26 3547 77 41 5738 65 24 7499 60 62 1974 44 50 4537 78 66 6823 92 13 6982 70 22 3085 96 40 1459 53 82 You may assume that each score is a positive integer and the data file contains at least one line. Mr. Lee writes a program to calculate the overall mean score of his students and find the students who obtained the highest average score. If there is more than one student with the highest average score, the program will find the first one. The program should produce the output below on the VDU. (In this output, all the data following a question mark is entered by the user through the keyboard. All other items are output from the program.) Sample output 1: File name? DATA1999.TXT Overall mean score: 58.63 Highest average score: 98.5 Student number of the best student: 0157 Sample output 2: File name? DATA2000.TXT Overall mean score: 55.40 Highest average score: 85.5 Student number of the best student: 3267

2001-CE-COMP STUD 1B & C-2 (C Version)

Mr. Lee’s program is shown below: Line Number 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300

Program Statement #include <stdio.h> int main() { int Test1, Test2, I, Count; double Score, MaxScore, Sum; char Num[5], MaxNum[5]; char fn[1024]; FILE* f; printf("File name? "); scanf("%s", "fn"); f = fopen(fn, "r"); strcpy(MaxNum, "0000"); MaxScore = 100; Count = 0; Sum = 0; while ( feof(f) ) { fscanf("%s%d%d", Num, &Test1, &Test2); Score = (double) Test1 + Test2 / 2; if ( Score < MaxScore ) { MaxScore = Score; } Sum = Sum + 1; Count = Count + 1; } fclose(f); printf("Overall mean score: %.2f\n", Sum / Count); printf("Highest average score: %.1f\n", MaxScore); printf("Student number of the best student: %s\n", MaxNum);

return 0; 310 } 320 However, there are several mistakes after line 80 in the program. Fill in the following table to show the location of each mistake and its correction. Line Number

Corrected Statement

(10 marks)

2001-CE-COMP STUD 1B & C-3 (C Version)

7.

The algorithm below converts a denary (base 10) number to a binary (base 2) number. Step 1: Declare dena, remdr to be integer variables, and newnum, bina to be strings. Step 2: Read a denary number into variable dena. Step 3: Assign a null string to bina. Step 4: As long as the value of dena is greater than 1, repeat steps 5 to 8. Step 5: Calculate the remainder when dena is divided by 2 and store the result to variable remdr. Step 6: Calculate the quotient when dena is divided by 2 and store the result to variable dena. Step 7: Convert the variable remdr to a string and store it in newnum. Step 8: Concatenate newnum and bina, then store the result in bina. Step 9: Convert the variable dena to a string and store it in newnum. Step 10: Concatenate newnum and bina, then store the result in bina. Step 11: Display the value stored in bina. Convert the algorithm into a C program.

(10 marks)

2001-CE-COMP STUD 1B & C-4 (C Version)

8.

The declaration of a global array variable list and procedure P are given below: #define true 1 #define false 0 int list[16]; void P(int t, int f, int e, int* r) { int m; int flag; flag = false; while ( !flag && f <= e ) { m = (f + e) / 2; printf("Before the Segment X, "); printf("f = %d e = %d m = %d\n", f, e, m); if ( list[m] == t ) flag = true; else if ( list[m] > t ) Segment X e = m - 1; else f = m + 1; printf("After the Segment X, "); printf("f = %d e = %d m = %d\n", f, e, m);

} if ( flag ) *r = m; else *r = -1; } (a)

Suppose the array variable list stores the following values: m 0 1 2 3 4 5 6 7 8 9 10 11 12 list[m] 10 14 17 24 33 36 39 48 56 61 69 77 82 The variable SearchResult is defined as integer. If the following statement is executed:

13 86

14 87

15 99

P(36, 0, 15, &SearchResult); write the output by completing the following: Before the Segment X, f =

e =

m =

After the Segment X, f =

e =

m =

Before the Segment X, f =

e =

m =

After the Segment X, f =

e =

m =

Before the Segment X, f =

e =

m =

After the Segment X, f =

e =

m = (4 marks)

2001-CE-COMP STUD 1B & C-5 (C Version)

(b)

Suppose the values in the array list are now in reverse order as follows: m list[m]

0 99

1 87

2 86

3 82

4 77

5 69

6 61

7 56

8 48

9 39

(i)

Rewrite Segment X so that procedure P can handle the above array.

(ii)

After the execution of the following statement:

10 36

11 33

12 24

13 17

14 14

15 10

P(41, 0, 15, &SearchResult); what is the value of SearchResult? (5 marks) (c)

What is the algorithm used in procedure P? (1 mark)

2001-CE-COMP STUD 1B & C-6 (C Version)

9.

In an election, there can be at most 30,000 candidates, numbered 1 to 30,000. Each voter can select only one candidate by writing the number of his/her preferred candidate on the ballot. Cindy is going to write a C program to perform the following tasks: Task A: Task B: Task C:

Input the number of candidates and initialize the number of votes received by each candidate. Count the ballots for the candidates by asking the candidate number selected in each ballot. If exactly one number is shown on a ballot, the number will be entered. No ballot with more than one number shown will be entered. The program stops counting when the user enters a ‘0’ as a candidate number. Display the result of the election in the following format:

Result ====== Candidate 1 |******* Candidate 2 |***** … … … In the chart, an asterisk (*) represents one vote. The following shows a sample output of the program. (In this output, all the data following a colon is entered by the user through the keyboard. All other items are output from the program.) Number of candidates: 3 Candidate Candidate Candidate Candidate Candidate Candidate Candidate Candidate Candidate Candidate

number number number number number number number number number number

(enter (enter (enter (enter (enter (enter (enter (enter (enter (enter

0 0 0 0 0 0 0 0 0 0

to to to to to to to to to to

Result ====== Candidate 1 |*** Candidate 2 | Candidate 3 |****

2001-CE-COMP STUD 1B & C-7 (C Version)

stop stop stop stop stop stop stop stop stop stop

data data data data data data data data data data

entry): entry): entry): entry): entry): entry): entry): entry): entry): entry):

3 1 3 3 4 68 3 1 1 0

Cindy has already written the declaration and the main body of the program. Some procedures are missing. Part of the program is as follows: #include <stdio.h> int vote[30001]; Missing procedures here int main() { int n; Init(&n); printf("\n"); CountBallots(n); printf("\n"); printf("Result\n"); printf("======\n"); ShowChart(n); return 0; } The following indicates the description of each identifier used in this program: Identifier vote

Description A global array used to store the numbers of votes received by candidates. For convenience, vote[0] is NOT used and vote[x] stores the number of votes received by candidate x. n a variable used to store the number of candidates. You are not allowed to add any new variable in answering the question. (a)

Complete the procedure parameter and write the procedure Init that will perform Task A. void Init( { int i;

)

} (3 marks)

2001-CE-COMP STUD 1B & C-8 (C Version)

(b)

Write the procedure CountBallots which will perform Task B. void CountBallots(int n) { int ballot;

} (4 marks) (c)

Write the procedure ShowChart which will perform Task C. void ShowChart(int n) { int i, j;

} (3 marks)

END OF SECTION B

2001-CE-COMP STUD 1B & C-9 (C Version)

Section C (16 marks plus a maximum of 4 marks for effective communication) 10.

Mr Lee has decided to connect some electronic and electrical devices in his home to make a CyberHome for the family. He has installed a network to link up a computer and all the existing devices with a communication box attached to each device. Existing connections of the communication boxes include lighting controls, microwave oven, stereo systems, TVs, etc. After the installation of the network and the computer, every device can only be controlled by the computer and each use of the device is recorded. When the computer is powered up, an application program is automatically started. It will show a screen of icons. Each icon represents a device. To use the application program, a user must place his/her own smart card on top of a reader while the user performs the operations. When a user double-clicks on an icon, the computer will send a message to the corresponding device to turn it on. When a user single-clicks on an icon, the corresponding device will be turned off. Each message sent by the computer contains a device number and a set of data items to control the corresponding device. The current design contains only a device number and one data item, which is for the ON/OFF control of the device. After using the system for a few days, Mr Lee’s family members have the following comments: • • •

(a)

Mr Lee’s wife said, “As the icons are arranged in alphabetical order, it is quite hard to find the right icon for an appliance using the CyberHome.” Sunny, Mr Lee’s elder son, said, “The idea of the CyberHome is excellent. However, I often need to walk back and forth from my room to the computer to control the devices which is inconvenient.” Apple, Mr Lee’s younger daughter, said, “I feel very uncomfortable since the installation of the CyberHome. Every time I want to turn on a light, I need to go to the living room. All of my activities are known to everyone. I would like to go back to the old days.” Suggest a solution for the icon arrangement problem which Mrs Lee complained about.

(2 marks) (b)

Sunny suggests installing microphones for voice recognition instead of using a mouse as the input device. Give ONE advantage and ONE disadvantage of this suggestion.

(4 marks)

2001-CE-COMP STUD 1B & C-10 (C Version)

(c)

Mr Lee wants to have remote control of his devices at home and connects his network to the Internet. After the connection, he can use his mobile phone to control his home devices. Give a potential risk that he may face when he remotely controls the devices.

(2 marks) (d)

Mr Lee wants to have one monthly device usage report of each member of his family. What essential data should be used to generate the report?

(2 marks) (e)

Apple thinks there has been an invasion of her privacy after the set up of the CyberHome. Give an example of privacy invasion that may occur after connecting to the Internet.

(2 marks) (f)

Apple opposes the idea of remote controlled home devices. She is afraid that Mr Lee can limit her access to the home devices, like the stereo or TV. Suggest the steps that the system will have to perform to handle local and remote requests differently and, thus, solve the problem raised by Apple.

(4 marks) END OF SECTION C END OF PAPER

2001-CE-COMP STUD 1B & C-11 (C Version)

A Partial Character List for ASCII Character 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I

ASCII 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

Character J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c

ASCII 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

Character d e f g h I j k l m n o p q r s t u v w x y z { | }

ASCII 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125

List of Operators and Reserved Words (C) #include, +, -, *, /, ++, --, +=, -=, *=, /=, %=, ==, %, >, <, =, >=, <=, !=, &&, ||, !, sqrt, rand, abs, strcat, strncat, strlen, atoi, strcpy, strncpy, const, void, return, int, float, char, \0, strcmp, strncmp, true, false, FILE, main, /*…*/, if…else, for, while, do…while, switch…case…break, break, continue, scanf, printf (%d, %f, %c, %s), \n, \t, fopen, getc, fgets, putc, fputs, EOF, fclose

2001-CE-COMP STUD 1B & C-12 (C Version)

Related Documents