Data type | Description | Sample data |
---|---|---|
INTEGER | Stores positive or negative whole numbers | 17 |
REAL | Stores numbers that contain decimal places/values and can also store integers | 17.65 |
CHARACTER | Stores a single character which can be a letter, number or symbol | $ |
STRING | Stores alphanumeric combinations and text. String is really a group of characters stored together as one. Numbers to be used for calculations should not be stored as string data even though they can be. They should be stored as INTEGER or REAL | Batman |
BOOLEAN | Stores True or False only. This is sometimes taught as 1 or 0 only where 1 is true and 0 false | True |
In a program, data values can be constant or variable. If values are variable they can be changed by the program and the user. When a program is run, the data values are held in memory whilst they are being worked on.
Constants: Data values that stay the same every time a program is executed are known as constants. Constants are not expected to change.
Variables: are data values that can change when the user is asked a question, for example, their age. Variables may change during program execution.
A variable is a memory location. It has a name that is associated with that location. The memory location is used to hold data. The key difference when comparing a constant to a variable is that the value associated with a variable name may change during program execution. For example 'highScore' would need to be variable to change throughout a game.
No comments:
Post a Comment