teach-ict.com logo

THE education site for computer science and ICT

2. Character and string

The 'character' data type is able to store a single letter, number or symbol such as 'A', 'b', $, 4.

Using the character data type is very efficient in terms of memory as a character is stored either in a single byte (8 bits) or a single word (word length depends on the cpu type) depending on the computer system.

character data type

Every alphabet in the world can be represented by an international standard called 'Unicode'.

String data type

Characters are strung together to form words and sentences. It is convenient to treat these as a single variable the data type for this is called 'string'.

Examples that use string
Item Description
Name Harry Potter
Address 29 Craft Avenue
Telephone number 022984848
Car Registration number CX45 829
Colours Blue

Note: Telephone numbers are stored as a string rather than an integer data type because an integer data type will remove any leading zeros from the number, thus 01926 becomes 1926. Also, no mathematics are likely to be carried out on such numbers.

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Character and String data type