Module: Control Flow

Welcome. In this module, we will explore how computer programs make decisions. But first, let's briefly review the data structure we will be analyzing today: Arrays.

Part 1: Concept Review - The Array

Click the cards below to reveal key concepts regarding Arrays.

What is an Array?

An array is a data structure that stores a collection of elements (values) under a single variable name. Think of it as a row of mailboxes, where each box has a specific index number starting at 0.
Click to reveal

The Purpose

Arrays allow us to manage large sets of related data efficiently. Instead of creating variables `score1`, `score2`, `score3`, we create one array `scores` containing all values.
Click to reveal

Cybersecurity Application

In security, arrays are used to store logs, packet headers, or whitelisted IP addresses. We iterate (loop) through these arrays to find anomalies or threats.
Click to reveal

Part 2: Types of Conditions

To analyze the data inside an array, we need Conditional Statements. These allow the code to perform different actions based on different boolean (True/False) states.

Condition Type Syntax Structure Best Use Case
If / Else if (condition) { ... } else { ... } Binary decisions. Example: Is this password correct? Yes or No.
Else If if... else if... else Checking multiple distinct conditions in sequence. Example: Is grade > 90? No. Is grade > 80?
Switch Statement switch(val) { case x: ... break; } When a variable has specific, discrete values. Example: Menu selections (1=Open, 2=Save, 3=Exit).
Ternary Operator (condition) ? trueVal : falseVal Short, one-line assignments. Example: status = (isOnline) ? "Connected" : "Offline"

Part 3: Activity - The Threat Hunter

Scenario: You are analyzing an array of Network Packet Sizes. Normal traffic packets are usually small (< 50 bytes). Large packets (> 80 bytes) often indicate a data exfiltration attempt (a threat).

Task: Configure the firewall logic below to scan the array and flag the threats.

INCOMING TRAFFIC BUFFER (Array Index 0-6):
System Standby... Waiting for logic configuration.