Data Types & Variables
Data Types
Different types of data that can be stored and processed in programs.
| Type | Description | Examples |
|---|---|---|
| Integer | Whole numbers (no decimals) | 42, -7, 0 |
| Real/Float | Decimal numbers | 3.14, -2.5 |
| Boolean | True or False values | true, false |
| Character | Single letter or symbol | 'A', '5', '@' |
| String | Text (sequence of characters) | "Hello World" |
Variables
Named storage locations that hold data which can change during program execution.
Naming Conventions
- Use meaningful, descriptive names (studentName, totalScore)
- Start with a letter (not a number)
- No spaces - use camelCase or underscores
- Avoid reserved words (if, while, for)
Examples in Pseudocode
// Declaring and assigning variables
studentName ← "John Smith"
studentAge ← 17
isPassing ← true
averageScore ← 85.5
Constants
Values that don't change during program execution. Named in UPPERCASE by convention.
CONST TAX_RATE ← 0.10
CONST MAX_STUDENTS ← 30