teach-ict.com logo

THE education site for computer science and ICT

2. Character data type

The 'character' data type is able to store a single letter, number or symbol such as 'A', 'b', $, 4. These are symbols you will find on your keyboard.

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 depending on the computer system.

character data type

In a computer language such as Python, you can assign a single letter to a variable:

                      FirstLetter = 'A'

Python knows that a single letter can be stored in a character data type, so there is no need to declare the fact beforehand.

In other languages such as VisualBasic, you declare the type before using it :-

              Dim FirstLetter As Char
              FirstLetter = 'A'

In other languages such as Java, you can declare the type on the same line it is used :-

             char FirstLetter = 'A'

 

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 data type