Week 2 Arrays

lecture-notes 2026-06-13 2 backlinks

Week 2 - Arrays

Arrays

Fundamentally 3 different parameters:

  1. One Type ( Int, String, etc) - can be named too
  2. Name - Variable Name
  3. Size - How many boxes
  4. Is also 0-Indexed. Meaning it starts counting from Zero

Can also make them dynamically increase and dcerease the size of arrays.

int hours[5];

How to populate each cell?

int hours[5];
hours[0] = 7;
hours[1] = 1;

Computer knows i will allocate 5 cells into the bubble. You can modify and change the variable names with this one

Alternatively

int hours[5] = {1, 2, 3, 4, 5};

This will immediately assign all 5 hours/numbers into a specific sequence if you already know the values.

Strings are actually Arrays?!

A string is similar to an array. It stores a value of letters and assigns each letter from A-Z in a specific box

Strings are an array of characters…

string word = "Hello"

H = 0 E = 1 L = 2 L = 3 O = 4 /0 = 5 (Null)

Every string has a null character to specify where the string ends

string word = "Hello";

// If i use
word[0];
// It would store the letter "H"

Compilers

4 Steps Abstracted

  1. Preprocessing -> Calls the compiler and tells it that something will exist
#include <stdio.h>

The # is formally called a Preprocessor Directive. Anything with a ’#’ gets preprocessed

  1. Compiling ->Gets translated from C/another language to Assembly

  2. Assembly -> Converts again to binary.

  3. Linking -> Links all the #include files, finds the other header files and links the binaries that are linked together.

Decompiling

-> Converts binaries to code -> You can only reverse some processes -> When it comes to protecting your IP, its very difficult to decompile, -> Therefore, the people who are good enough to decompile can prolly make urs from scratch

Debugging

Debugging techniques

  1. The Rubber Duck! “Rubber ducking”
  • Talk to an inanimate object and sounding out what your problems are.
  1. Using printf -> Can reference memory. Most powerful debugging tool

  2. Spend a few minutes playing with a debugger. Debug50

Garbage Values

-> Value stored without being initialized/Leftover data

Types

bool int long float double char string

Data Structure

  1. Array
  • A continuous data type stored in memory that is a single type.

Command Line Arguments

Encryption

Contains three things:

  1. A Value - What you want to encrypt
  2. A Key - An algorithm to mathematically jumble the values. A simple one is Rot13 -> Rotating letters 13 times eg: A -> N
  3. Encrypted Value

All encrypted values must be able to be decrypted else it doesnt make sense.