Professional Documents
Culture Documents
COMP STUD
PAPER II
Instructions:
1. Read carefully the instructions on the Answer Sheet and insert the information required (including the
Subject Code) in the spaces provided.
2. When told to open this book, you should check that all questions are there. Look for the words ‘END OF
PAPER’ after the last question.
4. ANSWER ALL QUESTIONS. You should mark all your answers on the Answer Sheet.
5. You should mark only ONE answer for each question. If you mark more than one answer, you will
receive NO MARKS for that question.
A. 25.6 seconds
B. 51.2 seconds
C. 102.4 seconds
Which of the following formatting functions CANNOT D. 204.8 seconds
allow Peter to adjust the whole document on one page?
27. Which of the following error can be detected by a C (1) a file attachment
compiler? (2) an address book
(3) an instant messaging application software
A. a syntax error A. (1) only
B. a run-time error B. (2) only
C. a logic erro C. (1) and (2) only
D. an input error D. (1), (2) and (3)
28. Which of the following will make a computer program 34. Which of the following is responsible for carrying out
easy to read and understand? feasibility studies?
int main()
{
int x;
x = rand() % 10 + 1;
while ( x < 1 && x > 10 )
{
printf("%d", x);
x++;
}
printf("END\n");
}
A. END
B. 678910END
C. 12345678910END
D. The output cannot be determined.
int main()
{
int i;
char s[80], t[80];
strcpy(s, "ABCDEFGHIJ");
for ( i = 0; i < 10; i++ )
{
strcpy(t, s + i);
t[i + 1] = '\0';
strcat(s, t);
}
printf("%d\n", strlen(s));
}
A. 10
B. 20
C. 55
D. 65
int main()
{
int x[4];
char y[4];
int i;
x[0] = 1;
y[0] = 'A';
for ( i = 1; i <= 3; i++ )
{
x[i] = x[i - 1] + i + 1;
y[i] = y[i - 1] + x[i];
}
printf("%c\n", y[3]);
}
A. J
B. N
C. Q
D. T
int main()
{
int i;
A. END
B. 45END
C. 3456END
D. 12345678910END
int main()
{
int x;
x = 0;
while ( x <= 100 )
{
x += 10;
switch ( ((int) sqrt((double) x)) % 2 )
{
case 0:
printf("P");
break;
case 1:
printf("Q");
break;
}
}
printf("\n");
}
A. PQPQPQPQPQP
B. QPQPQPQPQPQ
C. PQPQPPQQPQQ
D. QPQPQQPPQPP
int main()
{
int err;
char text[80];
int i;
strcpy(text, "2001HKCEE");
err = -1;
for ( i = 0; i < 10; i++ )
if ( text[i] < '0' || text[i] > '9' )
{
err = i;
i = 9;
}
printf("%d\n", err);
}
A. -1
B. 3
C. 4
D. 5
int main()
{
int a[12];
int k;
a[0] = 1;
a[1] = 1;
for ( k = 2; k <= 7; k++ )
a[k] = a[k - 1] + a[k - 2];
printf("%d\n", a[7]);
}
A. 8
B. 13
C. 21
D. 34
int main()
{
char source[80], secret[80];
char e, d;
int i, tmp;
strcpy(source, "COMPUTER");
strcpy(secret, "");
A. UXPRPBZC
B. IRELTBBQ
C. PBZCHGRE
D. VYBIRLBH
int main()
{
if ( !((0 > -5) && (-7 < -5)) )
printf("1");
else if ( 'z' > 'Z' )
printf("2");
if ( strcmp("computer", "company") > 0 )
printf("3");
}
A. 2
B. 13
C. 23
D. 123
m = 3;
*y = m + x;
x = m + *y;
}
int main()
{
int a, b;
a = 4;
b = 5;
ONE(a, &b);
printf("%-5d%-5d\n", a, b);
}
A. 4 5
B. 4 7
C. 10 5
D. 10 7
#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
1. D 26. C
2. A 27. A
3. B 28. D
4. A 29. D
5. C 30. C
6. A 31. B
7. deleted 32. B
8. B 33. A
9. C 34. C
10. B 35. A
11. D 36. D
12. B 37. D
13. B 38. C
14. C 39. D
15. B 40. B
16. B 41. A
17. B 42. D
18. C 43. D
19. D 44. D
20. D 45. D
21. C 46. C
22. B 47. C
23. A 48. C
24. C 49. C
25. A 50. B
Note: Figures in brackets indicate the percentage of candidates choosing the correct answers.