Resources | Subject Notes | Computer Science
In computer programming, data types define the kind of value a variable can hold. Understanding data types is fundamental for writing correct and efficient programs. This section explores the core basic data types used in introductory programming.
Integers represent whole numbers – numbers without any fractional or decimal parts. They can be positive, negative, or zero.
Floating-point numbers represent numbers with decimal points. They can include fractional parts.
Characters represent a single letter, number, symbol, or punctuation mark.
Strings represent a sequence of characters. They are used to store text.
Data Type | Description | Examples | Typical Storage |
---|---|---|---|
Integer | Whole numbers (positive, negative, zero). | -5, 0, 10, 100 | Fixed number of bits (e.g., 8-bit, 32-bit) |
Float | Numbers with decimal points. | 3.14, -2.5, 0.0, 1.0 | Floating-point format |
Character | Single letter, number, symbol, or punctuation mark. | 'A', '7', '$', ' ' | Character encoding (e.g., ASCII, Unicode) |
String | Sequence of characters (text). | "Hello", 'IGCSE', "123 Main Street" | Series of characters |
Understanding these basic data types is crucial for choosing the appropriate data type for variables in your programs. This ensures that data is stored and processed correctly.