Which data type should be used to store whether a user is logged in?
Based on: AQA 8525 · 3.2.1
Section 3.2 is one of the two largest topics in the bank and the heart of Paper 1. It is sat in the language you were taught, from C#, Python and VB.NET. The ideas below are the same in all three. The questions here check the ideas. Paper 1 will ask you to write the code.
Which data type should be used to store whether a user is logged in?
Based on: AQA 8525 · 3.2.1
Which are the three basic programming constructs?
Based on: AQA 8525 · 3.2.2
What is the value of 17 MOD 5?
Based on: AQA 8525 · 3.2.3
An array is declared to hold 5 items and is indexed from 0. What is the index of the last item?
Based on: AQA 8525 · 3.2.4
These are the errors that turn up in answer after answer.
The core data types are integer for a whole number, real or float for a number with a decimal part, Boolean for True or False, character for one symbol, and string for a sequence of characters. Whether a user is logged in is a Boolean. A height in metres is a real, because 1.72 has a decimal part and an integer would lose it. A variable is a named store whose value can change while the program runs. A constant is a named value that cannot change once set, which makes a program easier to read and to update.
Sequence is one step after another. Selection chooses between paths with IF, ELSE IF and ELSE. Iteration repeats. Iteration comes in two kinds. Count-controlled loops, such as FOR, repeat a fixed number of times. Condition-controlled loops, such as WHILE and REPEAT UNTIL, repeat while or until a condition holds. Arithmetic operators include the usual four plus integer division, written DIV, and remainder, written MOD. MOD is the standard way to test whether a number is even or divisible by something. Relational operators compare two values and give a Boolean. Boolean operators combine conditions with AND, OR and NOT.
An array is a set of items of the same type stored under one name and reached by an index. Arrays are usually indexed from 0, so an array of 5 items has indexes 0 to 4. A two-dimensional array is an array of arrays, indexed with two values, typically row then column. A record stores several related values that may be of different types under one name, for example a name, an age and a member flag. A subroutine is a named block of code you can call. A procedure carries out a task. A function returns a value. Parameters pass data in and the return value passes a result back. Subroutines make programs shorter, easier to test and easier to reuse. A local variable exists only inside the subroutine that declares it. A global variable is visible throughout the program. Local variables are preferred because they cannot be changed by accident elsewhere.
String handling covers finding the length, extracting a substring or a single character by position, joining strings together, which is concatenation, and converting the case. Programs read from and write to files so that data survives after the program ends. The usual steps are open, read or write, then close. Validation checks that input is sensible before it is used: range checks, presence checks, length checks, type checks and format checks. Authentication checks who the user is, usually with a username and password. The two are different jobs and a question will usually want you to name the right one.
A syntax error breaks the rules of the language and stops the program running at all. A logic error runs fine and produces the wrong result, which is why testing matters. Test data should cover normal data, which is typical valid values, boundary data, which sits right at the edge of what is allowed, and erroneous data, which should be rejected. Iterative testing happens while you build, module by module. Final testing checks the whole finished program against what it was supposed to do.
| Syntax error | Logic error |
|---|---|
| Breaks the rules of the programming language. | Follows the rules of the language. |
| The program will not run at all. | The program runs and produces the wrong result. |
| Found by the translator before or during the run. | Found by testing with normal, boundary and erroneous data. |
| Usually quick to locate because the translator points at it. | Can hide for a long time because nothing appears to be wrong. |
DIV is integer division and gives how many whole times one number goes into another. MOD gives the remainder. So 17 DIV 5 is 3 and 17 MOD 5 is 2. MOD is the usual way to test whether a number is even.
In the languages used at GCSE they normally start at 0. An array of 5 items has indexes 0 to 4, and the last index of an array of n items is n minus 1.
Both are subroutines, which are named blocks of code you can call. A procedure carries out a task. A function returns a value. If it returns something, it is a function.
Validation checks that input data is sensible before it is used, with range, presence, length, type and format checks. Verification checks that data was entered or copied correctly, for example by asking for a password twice.
Normal data, boundary data and erroneous data. Normal data is a typical valid value. Boundary data sits at the edge of what is allowed. Erroneous data should be rejected. Marks are usually for all three together.
RiverMap Learning apps are independent study tools. They are not affiliated with, endorsed by, or connected to any government body or examination authority. Question content is original and based on publicly available official study materials.