You are on page 1of 3

Suggested Solutions to 2002 HKCEE Computer Studies Paper I Sections B & C (C Version)

6. Line Number Program Statement


180 char ch; 1
220 DiskFile = fopen(FileName, "r"); 1
225 TotalReplaced = 0; 1
230 while ( !feof(DiskFile) ) 1
270 fscanf(DiskFile, "%c", &ch); 1
280 if ( ch == SearchChar ) 1
300 printf("%c", ReplaceChar); 1
310 TotalReplaced = TotalReplaced + 1; 1
315 } 1
340 while ( ch != '*' ); 1
385 printf("\n"); 1
Max
10

7. Step 1 line 40 1
Step 2 line 60 1
Steps 3, 4 & 5 lines 70, 80 and 90 1
Step 6 lines 100, 110 and 180 1
Step 7 line 120 1
Step 8 line 130 1
Step 9 line 140 1
Step 10 line 150 1
Step 11 line 160 1
line 170 1
00 #include <stdio.h>
10
20 int main()
30 {
40 int former, latter, limit, cnt;
50
60 scanf("%d", &limit);
70 former = 1;
80 latter = 1;
90 cnt = 0;
100 while ( former <= limit )
110 {
120 printf("%d", former);
130 latter = former + latter;
140 former = latter - former;
150 cnt++;
160 if ( cnt % 6 == 0 )
170 printf("\n");
180 }
190 return 0;
200 }

8. (a) (i) when Count equals 0, Ch = A, Tmp = A, P = A. 1


when Count equals 0, Ch = B, Tmp = F, P = AF. 1
when Count equals 0, Ch = L, Tmp = D, P = AFD.
when Count equals 0, Ch = E, Tmp = U, P = AFDU.

SEC = AFDU. 1

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


(ii) void Decode(char* P, char* C) 1
{
char Ch;
char Tmp[2];
int Len, Count, Asc;

strcpy(C, "");
strcpy(Tmp, " ");
Len = strlen(P); 1
for ( Count = 0; Count < Len; Count++ )
{
Ch = P[Count];
Asc = (int) Ch - A;
Asc = (D * Asc) % N; 1
Tmp[0] = (char) (Asc + A);
strcat(C, Tmp); 1
}
}

(iii) AWIK 1

(b) Line 110 is changed to:


const int M = 5, D = 21, N = 26, A = 97; 1+1

9. (a) void InputWords()


{
printf("Input the first English word: "); 0.5
scanf("%s", word1);
printf("Input the second English word: "); 0.5
scanf("%s", word2);
}

(b) void CheckLength()


{
if ( strlen(word1) != strlen(word2) ) 1+1
match = false;
}

(c) void ChangeUpper(char* st) 1


{
int i;

for ( i = 0; i < strlen(st); i++ ) 1


if ( st[i] >= 'a' && st[i] <= 'z' ) 1
st[i] = st[i] - 'a' + 'A';
}

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


(d) void CalFreq()
{
int i;

for ( i = 0; i < strlen(word1); i++ )


{
freq1[word1[i] - 'A']++; 1
freq2[word2[i] - 'A']++; 1
}
}

(e) void CheckMatching()


{
int i;

for ( i = 0; i < 26; i++ ) 1


if ( freq1[i] != freq2[i] ) 1
match = false;
}

10. (a) (i) Web page browsers can be used. 1

(ii) We can use data encryption to protect data from unauthorised access. 1

(b) Data entry operator / programmer / web page designer (any two) could help Amy. 1, 1

(c) 1. Electronic mail service can provide 24-hour enquiry service. (time) 1
2. Customers can make enquiries all over the world. / 1
Customers are not necessary to visit the bookstore by person. (location)
3. Staff can answer customers’ enquiries on batch./ 1
Staff can answer similar enquiries quickly. (management)

(d) 1. The web site can provide a search engine for customers to search books. (enquiry)
2. The web site can provide online order/payment/reservation service for customers to order/buy
books. (payment)
3. The web site can display new release books / top selling books / discounted books so that
customers can collect more information about our store. (display)
4. The web site can provide a bulletin board / chat room for customers to feed back our services.
(communication / customers’ opinion)
(any three)
2, 2, 2

(e) 1. Constructing the web site requires a high investment on web server development. (cost) 1
2. Customers are not used to buy books online. (customers’ habit) 1
3. There is a security risk on the Internet that affects customers to use the web site. (Internet 1
security)

Effective communications:

Relevance 0 / 1 /2

Language/Style 0/1/2
correct and
appropriate

0/1/2/3/4

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

You might also like