Data Types in Programming: Integer to Boolean

Understand how computers organize information and why data types matter in CSEC IT!

1

Why Do Data Types Matter?

Memory Allocation

The computer needs to know how much space to set aside for each piece of data. A whole number (like 42) takes up less memory than a long sentence (like "The quick brown fox jumps over the lazy dog").

Allowed Operations

Data types tell the computer what operations are allowed. You can multiply two numbers, but you can't multiply two names. This prevents logical errors in programs.

The Square Peg in a Round Hole

Try to drag a "Word" into the "Math Calculator." See what happens when you use the wrong data type!

"Hello"

Math Calculator

Ready for numbers...

Accepts: Integer, Float

2

Integer: The Whole Numbers

INT Integer

Definition: Positive or negative whole numbers with no fractional parts.

CSEC Examples: Age (15), Number of students (30), Year (2026)

Range: Typically -32,768 to 32,767 (in some systems)

Integer or Not?

Click only the integers to build a "Digital Tower"!

15
10.5
-2
0
3.14
100
-5.5
7

Your integer tower will appear here...

3

Real / Float: The Decimals

FLOAT Float (Real)

Definition: Numbers that contain fractional parts or decimal points.

CSEC Examples: Price ($19.99), Weight (150.5 lbs), GPA (3.8)

Precision: Used for measurements and money where exact values matter

The Precision Slider

Drag the slider to see how precision changes from Integer to Float with scientific measurement!

1
Integer (1) Float (1.0000)
Data Type: Integer

Scientific Measurement Example:

In chemistry, we measure 1.0000g (float) not 1g (integer) because precision matters!

4

String vs. Character: Handling Text

CHAR Character

Definition: A single letter, number, or symbol (e.g., 'A', '$', '7')

Memory: Typically 1 byte per character

STR String

Definition: A sequence or "string" of characters (e.g., "Jamaica", "CSEC IT 2026")

The "Number as Text" Trap: Phone numbers and ZIP codes are stored as Strings, not Integers (we don't do math with them!)

String Builder

Drag individual "Character" blocks together to form a "String" word!

C
S
E
C
I
T

Drag characters here to build a string...

5

Boolean: The Logical Choice

BOOL Boolean

Definition: Can only hold one of two values: True or False (or Yes/No, 1/0)

The "Switch" Metaphor: Like a light switch - it's either ON or OFF

CSEC Examples: Is_Graduate, Fees_Paid, Game_Over, Password_Correct

Logic Toggles

Toggle the switches to see how Boolean values work in programming!

Is the student a graduate?
False
Are the fees paid?
False
Is the game over?
False

Boolean Values in Code:

boolean isGraduate = false;
boolean feesPaid = false;
boolean gameOver = false;
6

Type Compatibility & Errors

Data Type Mismatch

What happens when you try to save "ABC" into an Integer variable? You get a Runtime Error or Type Error!

Type Casting

Converting one data type to another (e.g., changing the string "5" into the integer 5). This must be done carefully to avoid data loss.

The Bug Scanner

Find the data type error in this code! Click on the line with the bug.

int studentAge = 15;
float gpaScore = 3.8;
string studentName = "Maria";
int phoneNumber = "876-555-1234";
boolean isGraduate = false;

Hint: Phone numbers should be stored as strings, not integers!

7

Knowledge Check: The Data Type Challenge

The Data Type Categorizer

Select the correct data type for each piece of data!

Data Select Data Type
30.5
"Password123"
False
500
3.14159

Exam Scenario

"Which data type is most appropriate for storing a student's middle initial? Why?"

Scroll to Top