Variables are areas in memory where a value can be stored. They can be thought of as boxes into which data can be placed. All variables have a specific type. These types correspond to different types of information.
Examples
Number : 7.435
Name : 'Alice'
Age : 31
Each different type of data has it's own data type. These data types are used so that it is easier and safer to manage information.
Data Types
Char : This consists of a single character from the ASCII (or other) table.
eg. 'A', 'z', '0', ';'
Strings : Stores everything as text. Basically an array (or series) of characters.
eg. 'Alex', 'Year 2007', 'Hello World 89'
Integer : This is a number that has no decimal places. It can be used in arithmetic operations.
eg. 7, 9, 2 + 2
Real : A number with a decimal part. It can also be used in arithmetic operations.
eg. 7.01, 7.0, 3.142
Boolean : This is a variable which stores either true of false.
eg. True, False
Different programming languages may have custom data types used to deal with
specific types of data. Examples can include dates, currencies and times.
These variable types vary from language to language.
|