AQA A-Level Computer Science 7517
Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation
Fundamentals of Data Representation
Fundamentals of Computer Systems
Fundamentals of Computer Organisation and Architecture
Fundamentals of Communication and Networking
Consequences of Uses of Computing
Systematic Approach to Problem Solving
Fundamentals of Databases
Big Data
Fundamentals of Programming
Data types
- 3 things to know
- Paper 1
Overview
Recall questions on the integer, real, Boolean, character and string types, why each variable is declared with one, and why the character '7' is not the number 7.
What you need to know
Answer each one before you reveal it.
Describe the Boolean data type.
What is a user-defined data type?
Questions from this subtopic
Each one with the model answer underneath.
- 1
What is a data type?
Model answer
A data type defines the set of values a variable of that type may hold, the operations that may legally be performed on it, and how the value is represented in memory. Declaring a type tells the translator how much memory to reserve for the variable and how to interpret the bit pattern stored there.
- 2
Give three reasons why declaring the data type of every variable is useful.
Model answer
The translator can reserve the correct amount of memory and interpret the stored bit pattern correctly, and it can detect type errors before the program runs, for example an attempt to subtract one string from another. Declared types also document the programmer's intention for anyone later reading or maintaining the code.
- 3
Describe the integer data type.
Model answer
A whole number with no fractional part, which may be positive, negative or zero — −7, 0 and 4096 are all integers. Unlike a real, an integer is held exactly, so comparing two for equality is safe and no rounding error accumulates. The arithmetic available on integers is the ordinary four operations, together with the pair that only makes sense for whole numbers: integer division, which discards any fraction, and the remainder that division leaves behind.
- 4
Describe the real (float) data type.
Model answer
A number that may have a fractional part, for example 3.14 or -0.5. It is normally stored as a mantissa together with an exponent, so only a limited number of significant digits is kept and most real values are held as a close approximation rather than exactly.
- 5
A program counts how many pupils are in a room. Explain why integer is a better choice of type than real.
Model answer
The value can only ever be a whole number, so an integer represents it exactly, occupies less memory and is faster to work with. A real would permit meaningless values such as 27.4 and, because reals are stored approximately, a test such as count = 27 could fail even when the count really is twenty-seven.
- 6
Describe the Boolean data type.
Model answer
A type with exactly two possible values, True and False. It is what a relational or logical expression evaluates to, and it is used to control selection and iteration. Logically it needs only a single bit, although a language will usually reserve a whole byte for it.
Other ways to work this
The same content, four other ways.
What is inside Levo
Six ways to work the same material.
Every question in Fundamentals of Programming, on a schedule.
Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.
Or £46 a year, about £3.83 a month. Cancel anytime.