2210/21 · May/June 2025
Download PDFFour requirements for validating inputs and five types of validation check are given.
Draw one line from each requirement to the most appropriate validation check. Not all validation checks will be used. Requirement Date of birth must be between 01/01/1900 and 01/01/2010. Name has been entered. Password has exactly 12 characters. Student ID must contain 2 letters followed by a 4-digit number. Validation check length check format check range check check digit presence check
Identify and describe one verification check that could be applied when a new password is input into a system. Verification check ...................................................................................................................... Description ................................................................................................................................ ................................................................................................................................................... ................................................................................................................................................... ...................................................................................................................................................
The following pseudocode algorithm uses a count-controlled loop to read in 10 names and store them in the array Names[] FOR Count ← 1 TO 10 OUTPUT "Please enter a name" INPUT Name Names[Count] ← Name NEXT Count Rewrite the algorithm in pseudocode, using a condition-controlled loop instead of a count-controlled loop.
A telephone number with 13 characters is input. The first character is a ‘+’, followed by a 2-digit country code, for example: +20xxxxxxxxxx where 20 is the country code and x is a digit between 0 and 9 inclusive. The algorithm includes checks for the country codes: 44 for the UK and 20 for Egypt.
Write an algorithm using pseudocode to: • input the telephone number • extract the 2-digit country code • output the matching country • output ‘Unknown’ if there is no matching country.
Explain how you could change the algorithm to repeatedly prompt for the telephone number until the number entered is 13 characters in length. Any code used must be fully explained.
Two library routines used in programming are MOD and DIV. State the purpose of each of the library routines. Give one example pseudocode statement for each of the library routines. MOD purpose ................................................................................................................................... .......................................................................................................................................................... Example pseudocode ...................................................................................................................... .......................................................................................................................................................... DIV purpose ..................................................................................................................................... .......................................................................................................................................................... Example pseudocode ...................................................................................................................... ..........................................................................................................................................................
An algorithm has been written in pseudocode to generate a random integer between 1 and 100 inclusive and store the value in N. The user enters a guess for the number and the algorithm indicates whether the guess is higher or lower than the random number. The algorithm outputs the number of guesses when the user has correctly guessed the random number. 01 Counter ← 0 02 N ← ROUND(RANDOM() * 99, 1) + 1 03 REPEAT 04 OUTPUT "Please enter a guess" 05 INPUT G 06 IF G > N 07 THEN 08 OUTPUT "The number is lower than your guess" 09 ELSE 10 IF G < N 11 THEN 12 OUTPUT "The number is lower than your guess" 13 ENDIF 14 Counter ← Counter + 1 15 ENDIF 16 UNTIL G = N 17 OUTPUT "Well done, you took ", Guess, " attempts"
Identify the line numbers of the four errors in the pseudocode and suggest a correction for each error. Error 1 line number ............................ Correction ................................................................................................................................. ................................................................................................................................................... Error 2 line number ............................ Correction ................................................................................................................................. ................................................................................................................................................... Error 3 line number ............................ Correction ................................................................................................................................. ................................................................................................................................................... Error 4 line number ............................ Correction ................................................................................................................................. ...................................................................................................................................................
Identify one method to make the algorithm maintainable. Give an example.
Consider the logic expression:
Draw a logic circuit for this logic expression. Each logic gate must have a maximum of two inputs. Do not simplify the logic expression.
Complete the truth table for the given logic expression.
A bus company has set up a new database table called BUS to store details of the buses leaving the main bus terminal. RouteID | Destination | Stops | Driver | Time | Return BC01 | Town Centre | 10 | B Smith | 9:00 | Yes BC02 | The Fountain | 5 | A Patel | 9:10 | Yes BC03 | The Palace | 9 | B Hayes | 9:28 | No BC04 | City Park | 12 | W Gao | 9:55 | Yes BC05 | City Mall | 9 | R Hussein | 10:10 | No BC06 | Swan Lake | 14 | S Clarke | 10:33 | No BC07 | Guildhall Square | 7 | J Page | 11:34 | No BC08 | Sunset Quay | 6 | A Patel | 12:01 | Yes BC10 | Fort Worthington | 15 | E Carr | 12:01 | Yes BC12 | The Observatory | 18 | B Smith | 13:27 | No BC14 | East Seaport | 11 | B Scott | 14:07 | No BC15 | The Football Ground | 12 | J Page | 14:46 | Yes BC19 | The Cricket Ground | 11 | B Hayes | 15:14 | No BC23 | Temple Ruins | 14 | W Gao | 16:16 | No BC27 | The University | 9 | A Patel | 16:45 | No
Identify one appropriate data type for the field Return
State the reason for the data type chosen.
Write the output from the structured query language (SQL) statement: SELECT RouteID, Destination, Time FROM BUS WHERE Driver = "A Patel";
Complete the SQL statement to display only the destination of the buses that have a return. SELECT ..................................................................................................................................... ................................................................................................................................................... ...................................................................................................................................................
The variables A and B are used in a program. A holds a whole number and B holds text.
Write pseudocode statements to declare the variables A and B
The function Odds(X) returns ‘Odd’ if the value of X is an odd number and returns ‘Even’ if the value of X is an even number. Write pseudocode statements to: • define the function • call the function using parameter A and store the return item in variable B Function definition .................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... Function call ............................................................................................................................. ...................................................................................................................................................
The flowchart represents an algorithm to calculate grades.










Complete the trace table for the algorithm, using the input data: 21, 46, 63, 91, 12
Explain how the flowchart can be changed to produce the correct output.
The one-dimensional (1D) array CompetitorName[] contains the names of 25 competitors in a tournament that includes five events. Another two-dimensional (2D) array CompetitorScore[] contains the points scored by each competitor in the five events. The first dimension of this array contains the index of the competitor from CompetitorName[] and the second dimension contains their scores. Each competitor receives a score out of 100 for each event. These scores are manually entered into CompetitorScore[] Medals are awarded to the competitor or the competitors who have: • the highest points scored in each of the five events • the highest total points scored for all five events. The one-dimensional (1D) array Points[] stores the total number of points scored for each competitor. Write a program that meets the following requirements: • takes as input, valid scores (between 0 and 100), for each competitor in each of the five events • calculates the highest points scored for each event • outputs the names of the competitors who receive a medal for the highest points scored • calculates the highest total points scored for the five events • outputs the names of the competitors with the highest total points scored for the five events. You must use pseudocode or program code and add comments to explain how your code works. You do not need to declare any arrays or variables. All inputs and outputs must contain suitable messages.






