0478/21 · May/June 2024
Download PDFFour descriptions of programming concepts and five programming concepts are shown.
Draw one line to link each description to the most appropriate programming concept. Not all programming concepts will be used. Description: - a subroutine that may not return a value - a value that is declared and used within a specific procedure - a value that a procedure expects you to supply when it is called - a subroutine that will always return a value Programming concept: - function - procedure - parameter - global variable - local variable
Write the pseudocode to use a procedure named Average that passes the values 25 and 50 to the procedure.
Outline the role of procedures and functions in creating a program that is easier to maintain.
State what is meant by the data types integer and real. Give an example of each. Integer .............................................................................................................................................. .......................................................................................................................................................... Example ........................................................................................................................................... Real .................................................................................................................................................. .......................................................................................................................................................... Example ...........................................................................................................................................
This pseudocode algorithm is intended to allow, at random, between 1 and 20 values to be entered and totalled. The total and average of the entered values are output at the end of the algorithm. 01 DECLARE Loop : STRING 02 DECLARE Limit : INTEGER 03 DECLARE Value : REAL 04 DECLARE Total : REAL 05 Total ← 0 06 Limit ← ROUND(RANDOM() * 19,0) + 1 07 IF Loop ← 1 TO Limit 08 OUTPUT "Enter a number" 09 INPUT Loop 10 Total ← Total * Value 11 NEXT Loop 12 OUTPUT "The total of the numbers entered is ", Total 13 OUTPUT "The average of the numbers entered is ", Total / Limit
Identify the line numbers of four errors in the pseudocode and suggest corrections. Error 1 line number ................................................................................................................... Correction ................................................................................................................................. ................................................................................................................................................... Error 2 line number ................................................................................................................... Correction ................................................................................................................................. ................................................................................................................................................... Error 3 line number ................................................................................................................... Correction ................................................................................................................................. ................................................................................................................................................... Error 4 line number ................................................................................................................... Correction ................................................................................................................................. ...................................................................................................................................................
Write the pseudocode statement that would output the average calculated in line 13 of the algorithm rounded to one decimal place.
Explain how you should alter the original corrected algorithm to make sure that all the numbers entered are between 1 and 500 inclusive. If any numbers fall outside these limits, a replacement value is requested and entered. You do not need to re-write the algorithm.
Write the pseudocode statements to perform this task: • accept the input of a whole number from 1 to 4 inclusive • use a CASE statement to: ○ output the number (1 to 4 inclusive) that was entered ○ output the word “ERROR” if a 1 to 4 inclusive number was not entered.
The flowchart represents an algorithm.

Complete the trace table for the input data: 7, 47, 50, 52, 60, 80, 63, 70
Outline the processes involved in the algorithm shown in the flowchart on page 6.
Outline why it is useful to store data in a file.
The function LENGTH(X) calculates the length of a string X Write the pseudocode statements to: • read the contents of the text file Quotation.txt into an appropriate string variable that has been declared • output the string in upper case and the length of the string.
Consider the logic expression: Z = (R OR NOT T) XOR (NOT S AND T)
Draw a logic circuit for this logic expression. Each logic gate must have a maximum of two inputs. Do not simplify this logic expression.
Complete the truth table from the given logic expression.
A database table called SoftDrinks stores details of the soft drinks sold by a small shop. Field | Example data Name | Cola Supplier | Cambridge Beverages Container | Can SizeCl | 330 NumberInStock | 30 ReorderLevel | 15 Reordered | Yes
State whether any of the given fields would be suitable as a primary key and give a reason for your answer.
Complete the structured query language (SQL) statement to return the number of cans the shop has in stock. SELECT ....................................................... (.......................................................) FROM ....................................................... WHERE ....................................................... = ....................................................... ;
The one-dimensional (1D) array Clubs[] is used to store the names of 12 cricket clubs in a local sports league. The two-dimensional (2D) array Statistics[] is used to store, for each cricket club, the number of: • matches won • matches drawn • matches lost. The 1D array Points[] is used to store the total number of points each cricket club has been awarded. The position of any cricket club’s data is the same in all three arrays. For example, the data in index 2 of Statistics[] and index 2 of Points[] belongs to the cricket club in index 2 of Clubs[] The variable Matches stores the number of matches played by each team. Each team plays the same number of matches. Points are awarded for: • a win – 12 points • a draw – 5 points • a loss – 0 points. Write a program that meets the following requirements: • allows the number of matches played to be input and stored, with a maximum of 22 matches • validates the number of matches played • allows the names of the cricket clubs to be input and stored • allows the number of matches won, drawn and lost to be input and stored for each team • validates the number of matches won, drawn or lost against the number of matches played • asks the user to re-enter the number of matches won, drawn or lost if the total does not match the number of matches played • calculates and stores the total number of points for each club • finds the cricket club or clubs with the highest number of points • outputs the name or names of the winning club or clubs, the number of wins and the total number of points awarded. 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; you may assume that this has already been done. All inputs and outputs must contain suitable messages.






