Data Types (Cambridge (CIE) A Level Computer Science): Revision Note
Exam code: 9618
Primitive data types
What are data types?
A data type is a classification of data into groups according to the kind of data they represent
Computers use different data types to represent different types of data in a program
The basic data types include:
Integer: used to represent whole numbers, either positive or negative
Examples: 10, -5, 0
Real: used to represent numbers with a fractional part, either positive or negative
Examples: 3.14, -2.5, 0.0
Char: used to represent a single character such as a letter, digit or symbol
Examples: 'a', 'B', '5', '$'
String: used to represent a sequence of alphanumerical characters
Examples: "Hello World", "1234", "@#$%"
Boolean: used to represent true or false values
Examples: True, False
Date: used to store a calendar date
Example: DD/MM/YY
It is important to choose the correct data type for a given situation to ensure accuracy and efficiency in the program
In pseudocode and some other programming languages, data types must be declared before they can be used
The data types are declared with each data item to be used
Each data item is given a unique name called an identifier
DECLARE <identifier> : <data type>
Data Type | Example Value | Pseudocode | Python | Java | VB.NET |
---|---|---|---|---|---|
Integer |
|
|
|
|
|
Real |
|
|
|
|
|
Char |
|
|
|
|
|
String |
|
|
|
|
|
Boolean |
|
|
|
|
|
Date |
|
|
|
|
|
You've read 0 of your 5 free revision notes this week
Unlock more, it's free!
Did this page help you?