Understanding data types is fundamental to programming. Different types of data are stored and processed differently by computers.
Primitive data types are the basic building blocks for storing data in programs. They define what kind of data a variable can hold and what operations can be performed on it.
Integer
An integer is a whole number, positive or negative, with no decimal point.
Valid integers: 42, -17, 0, 1000000
NOT integers: 3.14, "42", 5.0
Real (Floating Point)
A real number (or float) is a number that can have a fractional part, represented with a decimal point.
Valid reals: 3.14, -0.5, 100.0, 2.71828
Boolean
A Boolean can only have two values: True or False. Used for logical operations and conditions.
isLoggedIn = True
hasPermission = False
isAdult = age >= 18 // Result is True or False
Character
A character is a single symbol - a letter, digit, punctuation mark, or special symbol.
Valid characters: 'A', 'z', '7', '!', ' '
Each character has a numeric code (ASCII/Unicode)
String
A string is a sequence of characters, used to represent text.
name = "Alice Smith"
empty = ""
number = "42" // This is a STRING, not an integer!
Integer
• Description: Whole numbers
• Example: 42, -7, 0
Real/Float
• Description: Decimal numbers
• Example: 3.14, -0.5
Boolean
• Description: True or False
• Example: True, False
Character
• Description: Single symbol
• Example: 'A', '7'
String
• Description: Text
• Example: "Hello"