Vous êtes sur la page 1sur 2

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

7. (a) A check digit is an extra digit to validate a code / to check the correctness of a code 1

(b) (i) 2
Values of i just after executing the for loop n sum

0 4 4

1 3 7

2 14 12

3 3 15
All correct for n: 1 mark
All correct for sum: 1 mark

(ii) (1) 28
(2) invalid card number

(c) for ( i = 0; i < strlen(x); i++ ) 1


if ( x[i] < '0' || x[i] > '9' ) 1
flag = false;
if ( !flag ) 1
printf("Digits from \"0\" to \"9\" only!\n");

(d) if ( sum % 10 == 0 ) 1
printf("Calculated check digit is 0\n");
else 1
printf("Calculated check digit is %d\n", 10 - (sum % 10));

OR:

printf("Calculated check digit is %d\n", (10 - (sum % 10)) % 10); 2

8. #include <stdio.h>
int main()
{
int NUM, COUNT, LOWER, UPPER; 1

scanf("%d %d", &LOWER, &UPPER); 1


NUM = LOWER; 1
while ( NUM <= UPPER ) 1
{
COUNT = 2; 1
while ( (NUM % COUNT) != 0 ) 1
COUNT++; 1
if ( NUM == COUNT ) 1
printf("%d\n", NUM); 1
NUM++; 1
}
return 0;
}

9. (a) char* secret 0.5


fopen 0.5
“r” 0.5
feof(fp) 0.5

(b) void init()


{
for ( i = 0; i < strlen(secret); i++ ) 1
solution[i] = '*';
solution[strlen(secret)] = '\0';
noOfAttempts = 2 * strlen(secret); 1

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


}

(c) void letterGuess()


{
char inp[80];

printf("Please input the letter you guess: "); 1


scanf("%s", inp);
letter = inp[0];
for ( i = 0; i < strlen(secret); i++ ) 1
if ( letter == secret[i] ) 1
solution[i] = letter;
printf("%s\n", solution);
noOfAttempts--; 1
printf("No. of attempts remaining = %d\n", noOfAttempts);
}

(d) void winCheck()


{
if ( strcmp(solution, secret) == 0 || noOfAttempts == 0 ) 1
done = true; 1
}

10. (a) trackball, touch screen, touch pad, trackpoint, joystick (any two) 1+1

(b) (i) Smart cards can be lost / counterfeited / stolen. 1

(ii) fingerprint recognition 1+1


voice recognition
retina recognition
(any two)

(c) (i) They want to withdraw / deposit cash. 1

(ii) It is more secure. 1

(d) (i) ATM kiosk 4 and ATM kiosk 6

(ii) optical fiber (fibre) / twisted pair / UTP (any one) 1

(iii) Data sent across the data line is encrypted (encoded) into 1
unreadable strings of messages. 1

The coded strings of messages are decrypted (decoded) at the receiving end. 1

(e) Once the database in a district computer is updated, messages should be sent to other district computers for 2
synchronizing the copies of the database. (update the databases in the other computers)

(f) Customers will spend more time at the ATM kiosks in waiting the process. (loading) 2
If the district computer C is out of order, all ATM kiosks cannot be operated. (reliability) 2

Effective communications:

Relevance 0 / 1 /2

Language/Style 0/1/2
correct and
appropriate

0/1/2/3/4

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

Vous aimerez peut-être aussi