Learn Extracted exam questions IGCSE Computer Science 0478_s25_qp_22
0478_s25_qp_22
Source PDF on the left, extracted YAML on the right. Compare numbering, marks, options and text.
Tick ($\checkmark$) \textbf{one} box to complete the description of abstraction.
Abstraction is part of the analysis stage of the development life cycle. Abstraction means
A fence measuring 2 metres in height and 20 metres in length needs painting. The area of the fence needs to be calculated so that enough paint for the job is purchased.
After the task is decomposed, there are three component parts: input, process and output.
\textbf{Three} component parts and \textbf{four} example descriptions are shown.
Draw \textbf{one} line from each component part to the most appropriate relevant description. \textbf{Not} all descriptions will be used.
\begin{tabular}{cc} \textbf{Component part} & \textbf{Description} \ & \ & \framebox{the height of the fence \quad the length of the fence} \ \framebox{process} & \ & \framebox{The amount of paint required is 40 square metres.} \ \framebox{output} & \ & \framebox{the colour of the paint} \ \framebox{input} & \ & \framebox{The area of fence is calculated as 40 square metres.} \ \end{tabular}
A range check is used to validate that the input temperature is an integer between $-100$ and $0$, inclusive.
Suggest suitable normal, abnormal, extreme and boundary test data to test if this validation check is working correctly.
Normal test data \hrulefill
Abnormal test data \hrulefill
Extreme test data \hrulefill
Boundary test data \hrulefill
State \textbf{one} reason for using a verification check when inputting data.
Write the pseudocode for an algorithm to perform a double entry verification check, using the following criteria:
\begin{itemize} \item Input 10 numbers and store them in the array \texttt{Numbers[]} \item Input the same 10 numbers again; as each number is input, compare it with its corresponding number in the array \texttt{Numbers[]} \begin{itemize} \item if the numbers match, move on to the next number \item if the numbers do not match, display both numbers and ask for the number to be re-entered \item store the re-entered number in the corresponding array location and move on to the next number. \end{itemize} \item When all the numbers have been checked, display a message to say the check has been completed. \end{itemize}
You do \textbf{not} need to declare any arrays or variables for this algorithm.
This pseudocode algorithm should allow 500 names of people and their heights to be entered and stored in two one-dimensional (1D) arrays. The name of a person and the height of that person are in the same index in both the \texttt{Names[]} and the \texttt{Heights[]} arrays.
The algorithm performs as follows:
\begin{itemize} \item at the start, the following data is entered: \begin{itemize} \item name of person \item height of person in cm \end{itemize} \item the data is stored in the relevant arrays \item the heights of the people are totalled \item the shortest person is found \item at the end, the following is output: \begin{itemize} \item name of shortest person \item height of shortest person \item average height of all 500 people. \end{itemize} \end{itemize}
\begin{alltt} 01 DECLARE Names : ARRAY[1:500] OF REAL 02 DECLARE Heights : ARRAY[1:500] OF REAL 03 DECLARE Shortest : REAL 04 DECLARE Total : REAL 05 DECLARE Counter : INTEGER 06 DECLARE Index : INTEGER 07 Shortest <- 500 08 Index <- 0 09 Total <- 100 10 FOR Counter <- 1 TO 500 11 INPUT Names[Index] 12 INPUT Heights[Counter] 13 Total <- Counter + Heights[Counter] 14 IF Heights[Counter] < Shortest 15 THEN 16 Shortest <- Heights[Counter] 17 Index <- Counter 18 ENDIF 19 NEXT Counter 20 OUTPUT "The shortest height is ", Heights 21 OUTPUT "The shortest person is ", Names[Index] 22 OUTPUT "The average height is ", Total / 500 \end{alltt}
Identify the line numbers of \textbf{five} errors in the pseudocode and suggest a correction for each error.
Error 1 line number \hrulefill Correction \hrulefill
Error 2 line number \hrulefill Correction \hrulefill
Error 3 line number \hrulefill Correction \hrulefill
Error 4 line number \hrulefill Correction \hrulefill
Error 5 line number \hrulefill Correction \hrulefill
Write the pseudocode statement that will output the average height rounded to \textbf{one} decimal place.
Explain how you could change the corrected algorithm so that it will also: \begin{itemize} \item find the height of the tallest person. \item output the height of the tallest person at the end of the algorithm. \end{itemize}
Any program statements used must be fully explained.
This pseudocode is an algorithm.
\begin{alltt} DECLARE Word : STRING DECLARE V1 : INTEGER DECLARE V2 : INTEGER DECLARE Number : INTEGER DECLARE Index : INTEGER DECLARE L1 : CHAR DECLARE L2 : CHAR DECLARE Continue : BOOLEAN INPUT Number FOR Index <- 1 TO Number INPUT Word Continue <- TRUE V1 <- 1 V2 <- LENGTH(Word) WHILE Continue = TRUE AND V1 < V2 DO L1 <- SUBSTRING(Word, V1, 1) L2 <- SUBSTRING(Word, V2, 1) IF L1 <> L2 THEN Continue <- FALSE ELSE V1 <- V1 + 1 V2 <- V2 - 1 ENDIF ENDWHILE IF Continue = TRUE THEN OUTPUT "Successful" ELSE OUTPUT "NOT successful" ENDIF NEXT Index \end{alltt}
Complete the trace table for the algorithm, using the input data:
2, RACECAR, TREAT
\begin{tabular}{|c|c|c|c|c|c|c|c|c|} \hline \textbf{Number} & \textbf{Index} & \textbf{Word} & \textbf{Continue} & \textbf{V1} & \textbf{V2} & \textbf{L1} & \textbf{L2} & \textbf{OUTPUT} \ \hline & & & & & & & & \ \hline & & & & & & & & \ \hline & & & & & & & & \ \hline & & & & & & & & \ \hline & & & & & & & & \ \hline & & & & & & & & \ \hline & & & & & & & & \ \hline & & & & & & & & \ \hline & & & & & & & & \ \hline & & & & & & & & \ \hline & & & & & & & & \ \hline & & & & & & & & \ \hline \end{tabular}
State the purpose of the algorithm on page 6.
Explain how the algorithm knows when all the letters in the word have been checked so that it can stop checking.
The flowchart shows an algorithm that is used to input 50 numbers. Each number is stored in the variable \texttt{Value} when it is input. Any number input that is less than or equal to $-20$ or greater than or equal to 50 is rejected and re-input. The accepted numbers are added together as they are entered and the total and average of these numbers are output at the end of the algorithm.
Complete the flowchart.
Explain how you would alter the flowchart in \textbf{7(a)} so that it will individually store each accepted value as it is entered and then output all the numbers, one after the other, outside of the loop that inputs values.
You may include program statements or flowchart symbols in your answer, but they must be fully explained.
Draw the symbol for an XOR logic gate.
XOR logic gate symbol:
Complete the truth table for an XOR logic gate.
\begin{tabular}{|c|c|c|} \hline \textbf{A} & \textbf{B} & \textbf{X} \ \hline 0 & 0 & \ \hline 0 & 1 & \ \hline 1 & 0 & \ \hline 1 & 1 & \ \hline \end{tabular}
Consider the logic rules in the following table:
\begin{tabular}{|c|c|l|} \hline \textbf{Input} & \textbf{Binary value} & \textbf{Description} \ \hline \multirow{2}{}{\textbf{A}} & 0 & operator \textbf{not} present \ \cline{2-3} & 1 & operator present \ \hline \multirow{2}{}{\textbf{B}} & 0 & ignition key present \ \cline{2-3} & 1 & ignition key \textbf{not} present \ \hline \multirow{2}{*}{\textbf{C}} & 0 & operator code correct \ \cline{2-3} & 1 & operator code \textbf{not} correct \ \hline \end{tabular}
A crane is a machine with a long arm used to lift heavy objects. The crane will only move: \begin{itemize} \item if the operator is present and \item either the ignition key is present, or the operator code is correct. \end{itemize}
The crane moving is represented by $X = 1$.
Write the logic expression for the crane moving.
$X =$ \hrulefill
Complete the truth table for the crane moving.
\begin{tabular}{|c|c|c|c|} \hline \textbf{A} & \textbf{B} & \textbf{C} & \textbf{X} \ \hline 0 & 0 & 0 & \hspace{2em} \ \hline 0 & 0 & 1 & \ \hline 0 & 1 & 0 & \ \hline 0 & 1 & 1 & \ \hline 1 & 0 & 0 & \ \hline 1 & 0 & 1 & \ \hline 1 & 1 & 0 & \ \hline 1 & 1 & 1 & \ \hline \end{tabular}
A database table, \texttt{CapitalCity}, stores data about capital cities from around the world.
\begin{tabular}{|l|l|} \hline \textbf{Field} & \textbf{Description} \ \hline \texttt{Identification} & a unique identifier \ \hline \texttt{Name} & the name of the city \ \hline \texttt{Country} & the name of the country in which the city is located \ \hline \texttt{Continent} & the name of the continent in which the city is located \ \hline \texttt{Population} & the number of people living in the city \ \hline \texttt{Founded} & the year the city was founded \ \hline \texttt{AverageIncome} & average income of the city's population, in $, rounded to 2 decimal places \ \hline \texttt{Subway} & whether or not the city has an underground railway system \ \hline \end{tabular}
Complete the table by writing \textbf{one} appropriate field from \texttt{CapitalCity} for each data type.
Each field must be different.
\begin{tabular}{|c|c|} \hline \textbf{Data type} & \textbf{Field} \ \hline Boolean & \hrulefill \ \hline integer & \hrulefill \ \hline real & \hrulefill \ \hline text & \hrulefill \ \hline \end{tabular}
Complete the structured query language (SQL) statement to list only the name, country and population of all the cities in \texttt{CapitalCity} from the continent of Asia.
\begin{alltt} SELECT \hrulefill
\hrulefill CapitalCity
WHERE \hrulefill = \hrulefill ; \end{alltt}
A program is required to allow students to calculate the volume of a number of standard three-dimensional shapes. It will use functions to allow other shapes to be added in the future.
\textbf{Cuboid}
$\text{volume} = \text{base} \times \text{depth} \times \text{height}$
\textbf{Triangular prism}
$\text{volume} = 1/2 \times \text{base} \times \text{depth} \times \text{height}$
\textbf{Sphere}
$\text{volume} = 4/3 \times \text{Pi} \times \text{radius} \times \text{radius} \times \text{radius}$
Pi is a constant with value 3.142
Write a program that meets the following requirements:
\begin{itemize} \item Output a menu to ask the user for an input to indicate the shape for which a volume needs to be calculated, from the three shapes given or if they want to stop the program. The program must validate the input. \item Input the data needed to calculate the volume of the chosen shape, based on the given formulae. \item Create one function for each shape to calculate and return the volume using the given formulae. Each function uses the input data as parameters. \item Output the volume in the main program, rounded to two decimal places. \end{itemize}
The program continues until the user inputs the stop option from the menu.
You must use pseudocode or program code \textbf{and} add comments to explain how your code works.
All variables and constants used must be declared for this algorithm.
All inputs and outputs must contain suitable messages.