2.2: Data Types

Exam Board:
OCR

Specification:
2020

What are the different data types?

When programming, variables should be given appropriate data types.

Character

A single character, such as a letter, number or punctuation symbol.

Examples:

T

8

?

String

A sequence of characters, including letters, numbers and punctuation.

Examples:

Harry Waters

14:50pm

Ice Age 4

Integer

A whole number.

Examples:

475

-8432

56732

Real

Boolean

A decimal number.

Examples:

65.3

-321.1234

909.135

An answer that only has two possible values.

Examples:

True / False

Yes / No

0 / 1

Telephone numbers are always stored as a string, not an integer.

Be careful with punctuation.

32.10 is a real but £32.10 is a string.

Casting

Understand that data types may be temporarily changed through casting, and where this may be useful

Questo's Questions

2.2 - Data Types:

1. State . [5]

2. State which data type is most suitable for the following variables:

  • a. Age [1]

  • b. Surname [1]

  • c. Height (in metres) [1]

  • d. First Initial [1]

  • e. Phone number [1]

  • f. Right-Handed? [1]

3. Explain what casting is and give a programming situation in which it would be used. [2]

This page is still being updated.