0% found this document useful (0 votes)
2 views16 pages

Computer sci

The document contains a series of programming questions and answers, primarily focused on data processing, calculations, and algorithm design. Each question includes specific tasks, expected outputs, and marks allocated for correct responses. The content appears to be part of an assessment or examination for programming or computer science students.

Uploaded by

gokxbor
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)
2 views16 pages

Computer sci

The document contains a series of programming questions and answers, primarily focused on data processing, calculations, and algorithm design. Each question includes specific tasks, expected outputs, and marks allocated for correct responses. The content appears to be part of an assessment or examination for programming or computer science students.

Uploaded by

gokxbor
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/ 16

1

Total
otal R Weight Output

1.8 1.8

1 26.0

8.8 7.0

20.1 11.3

30.1 10.0

32.6 2.5

2 25.2

37.6 5.0

57.4 19.8

3 29.3

– 57.4, 3

(2 marks) (1 mark) 1 mark) (1 mark)


(–1 for each error) (allow follow through)
(then follow though) (from Total and Reject)

[5]
2 (a
Trace table set 1
A B C D E F Total Check Output

5 2 4 3 1 5 38 5 Accept

-----------------------------------(1 mark)-----------------------------------(1 mark)------


Trace table set 2
A B C D E F Total Check Output

3 2 1 0 7 3 45 1 Reject

-----------------------------------(1 mark)-----------------------------------(1 mark)------


[4]

(b) – (modulo 11) check digit calculation [1]

(c) 1 mark for identifying the problem, 2 marks for the solution
Problem – doesn’t deal correctly with remainder 10/a check digit of X
Solution – check Z for X as a final digit
– have a special case where check = 10
– accept where Check = 10 and F = X [3]
3

Total Reject Weight Output

0 0

1.8 1.8

1 26.0

8.8 7.0

20.1 11.3

30.1 10.0

32.6 2.5

2 25.2

37.6 5.0

57.4 19.8

3 29.3

–1 57.4, 3

(2 marks) (1 mark) 1 mark) (1 mark)


(–1 for each error) (allow follow through)
(then follow though) (from Total and Reject)

[5]
Question Answer Marks

4(a) 4
Value
Value C Calc2 OUTPUT

50
0 16

33
3 11

18
8 6 1

15
5 5

30
0 10
0

One mark for each correct column (max four)

4(b)
(b) two correct statements e.g. 2
• The program outputs a value
• That is divisible by 6 // 2 and 3
Question Answer Marks

5(a) One mark for correct input (PointsWon and PointsLost) 3


One mark for correct calculations (Difference)
One mark for correct output

PointsWon
PointsWon Po Difference OUTPUT

5000
000 526 Keep on trying

6055 2000 4055 Well done move up

7900 9800 -190 Sorry move down

3000 2150 850 Keep on trying

-1 67

5(b)
(b) three from: 3
• Add extra decision box …
• … before checking for difference greater than or equal to 1000
// change Is difference >= 1000 to >= 1000 and <= 5000
• Check for difference greater than 5000
• Add extra Output ‘Fantastic leap up two levels’…
• … before flowline returns to input
Question Answer Marks

6 5
Flag
lag Num Divisor Value OUTPUT

False 5

5 is prime

False 6

True 3 2

True 4

False 8

True 3 2

True 4 2

False 0

One mark for each correct column


Question Answer Marks

7(a) One mark for each correct column (Max 4) 4

Value D Diff2 OUTPUT

50
0 0 Accept: Extreme

75
5 25 Accept: Normal

99
9 49 Accept: Normal

28 Reject: Abnormal

82
2 32 Accept: Normal

150 Reject: Abnormal

–1

7(b) One mark per bullet point (Max 2) 2


• To output the type of test data
• … by performing a range check //… by checking if numbers are within the range 50 and 100 (inclusive) (or not).
8(a) One mark for each correct column 3

Password Passwor OUTPUT

(Please enter password)

Secret Reject

(Please enter password)

Secret Reject

(Please enter password)

VerySecret
VerySecret V Accept

(Please enter password)

Pa55word Pa55word Accept

(Please enter password)

999 Reject

8(b) four from: 4


• Position: before INPUT PasswordRepeat // at start
• …use a (variable) counter (for number of tries) or flag
• … initialise variable counter or flag

• Position after IF Length(Password) >= 8 THEN or after INPUT PasswordRepeat


• … insert REPEAT/WHILE/(conditional) loop

• Position after OUTPUT "Reject"


• … add one to counter (for number of tries)
• … output a message "Try again"
• … add INPUT PasswordRepeat

• Position after OUTPUT "Accept"


• … reset flag to show password matched

• Position after ENDIF


• … (insert UNTIL/ENDWHILE)to exit the loop after three tries or if the repeated password matches the original
Question Answer Marks

9(a) One mark for each correct column 5

Op
Op Value Value2 Ans OUTPUT
1
87
14 101
3
2
30 60
5
10
6 Input Error
4
10
2 5
0
Question Answer Marks

9(b) To work as a calculator // to add, subtract, multiply or divide a pair of numbers 1

9(c) To output/store the result/the value of Ans // Adding prompts for data entry. 1

Question Answer Marks

10(a) One mark per mark point, max five 5

MP1
1 correct Counter and Limit columns
MP2
2 correct Value column
MP3
3 correct First column
MP4
4 correct Last column
MP5
5 correct OUTPUT

Counter First Last Limit OUTPUT

0 0 8

1 6

2 60 6 606

3 622

4 844

5 64 2

6 74 7 747

7 7

8 12 1 121
10(b) One mark per mark point, max two 2
 checks for / outputs 3-digit numbers
 … where the first and last digit are the same

Question Answer Marks

11(a) One mark for each correct column 7


Counter Hot Cold
Cold Se
S OUTPUT

0 0

1 1 75

2 2 78

3 3 84

4 1 87 Too Hot

5 2 91 Too Hot

6 4 80

7 5 75

8 6 70

9 7 65

10 1 62 Too Cold

-1 30 30

11(b)  include a message to explain the value output / e. g. “The percentage of meals not served” // 1
outputting Hot, Cold and Serve

11(c)  updating the Serve variable // Serve  Serve + 1 1


Question Answer Marks

12(a) One mark per mark point, max seven 7


MP1
1 correct In column
MP2
2 correct Logic column
MP3
3 correct Test column
MP4
4 correct Number column
MP5
5 correct Store[Count] column
MP6
6 correct Count and Limit columns
MP7
7 correct Out and OUTPUT columns

Store
In Logi Test Number Count L Out OUTPUT
[Count]
0 5
1 TRUE 2 9
3
FALSE
2 TRUE 2 5
3 5
3 TRUE 2 8
FALSE
4 TRUE 2 10
FALSE
5 TRUE 2 7
3 7 2 5
1 7
Question Answer Marks

12(b) One mark per mark point, max two 2


 to find / output prime numbers
 … store prime numbers in an array

12(c) One mark per mark point, max three 3

MP1 insert a WHILE loop … // pre-condition loop


MP2 … after Input Number
MP3 … with a condition to enter the loop Number < 3
MP4 an error message included within the loop to ask for a re-entry of Number
MP5 …with another input prompt for Number
MP6 ENDWHILE closes the loop and the program carries on from REPEAT in the original algorithm

OR

One mark per mark point, max three

MP1 insert a REPEAT loop … // post-condition loop


MP2 … before Input Number
MP3 a conditional statement should be placed after Input Number
MP4 …to check if Number < 3
MP5 if the number entered is <3, an error message included within the loop to ask for a re-entry of Number
MP6 UNTIL Number >= 3 closes the loop and the program carries on from REPEAT in the original algorithm
Question Answer Marks

13(a) One mark per correct column, max four 4

Pointer Choice OUTPUT

1 F

6 Letter F is represented by Foxtrot

Another Letter? (Y or N)

1 D

4 Letter D is represented by Delta

Another Letter? (Y or N)

13(b)
(b) (Line search 1

13(c) One mark per mark point, max two 2

 The algorithm would not stop


 … because it would not have found the item it was seeking

Or

 The array would run out of values after the pointer reached 13
 the algorithm will crash
Question Answer Marks

14(a) One mark for each column F, C and T 5


Two marks for columns X[1] to X[5] all entries correct or
One mark for columns X[1] to X[5] with one error

F C X[1] X X[3] X[4] X T

10 1 5 7 11

0 1 10

1 2 1 10 10

1 5 10 10

1 7 10

0 1

14(b) One mark for each point 2


 (bubble) sort data in array
 in ascending order
Question Answer Marks

15(a) One mark per mark point, max six 6


 correct Total column
 correct Value column
 correct Five1 column
 correct Five2 column
 correct Ten1 and Ten2 columns
 correct OUTPUT column

T
Total
otal V Ten1 Ten2 OUTPUT

5 1 0.5 Rejected

50
50 1 5 5

50 5 10.4 Rejected

5
555
55 1 55 55.5 Rejected

57 11 11.4 Rejected

500 1 50 50

550 –1 550

15(b) One mark per mark point, max two 2


 to find if an input is divisible by (both 5 and) 10
 … add them together and output the total

You might also like