Programming Fundamentals

Programming fundamentals is where the pseudocode from the previous topic finally becomes something a computer actually executes, built from six ingredients that every general-purpose programming language shares no matter how different their syntax looks. A variable is a named storage location that holds a value and can be reassigned — `age = 25` creates a variable named `age` pointing at the number 25 somewhere in memory, and giving it a name instead of a raw memory address is the entire point: readable code over a bare address this series will cover directly in the memory and program execution topic. A data type tells the language what kind of value a variable holds and what operations make sense on it — an integer like 25, a floating-point number like 3.14, a boolean that is only ever true or false, a string of text like "hello" — and most languages either check these types at compile time (catching a mismatch before the program ever runs) or at run time (catching it only when the mismatched operation is actually attempted), a real design tradeoff different languages make differently. Operators combine and compare values: arithmetic operators (+, -, *, /) do math, comparison operators (==, <, >=) produce a boolean answer, and logical operators (AND, OR, NOT) combine boolean values together, which is exactly the Boolean-algebra machinery this series will formalize later in the digital logic topic. Conditions let a program choose between different paths based on a boolean test — `IF temperature > 100 THEN print "boiling"` — which is the direct, literal implementation of the branching a plain sequential list of instructions cannot do on its own. Loops repeat a block of instructions, either a fixed number of times (`FOR i = 1 TO 10`) or until some condition stops being true (`WHILE balance > 0`), which is how a program does a thousand or a million repetitions without a human writing the same line a thousand or a million times. Functions package a reusable chunk of logic under one name, optionally accepting input parameters and returning a result, which is decomposition from the previous topic made real: instead of solving the whole problem inline, a program calls `calculate_tax(price)` and trusts that smaller, separately-tested piece to do its one job correctly. A calculator program is the cleanest possible illustration of all six ingredients working together at once: variables hold the two numbers and the chosen operation, a data type decision governs whether division should produce a whole number or a fraction, conditions branch on which operator the user picked, a function wraps each arithmetic operation so the main program logic stays simple, and — if the calculator keeps running until the user quits — a loop keeps the whole thing alive between calculations.

Read two numbers and an operator
stored in variables: a, b, op
IF op equals plus
result = a + b
ELSE IF op equals minus
result = a - b
ELSE IF op equals times
result = a * b
Print result
the function returns a typed value, printed to the user
Loop back for another calculation
WHILE user has not chosen quit
A Variable Is a Named Box in Memory The name is for humans — the machine only sees an address age 25 type: integer price 19.99 type: float is_valid true type: boolean age = 25 age = age + 1 the second line reads the current value, adds one, and overwrites the same named box with the new result reassignment doesn't create a new box — it overwrites the existing one
A Loop Replaces a Thousand Copy-Pasted Lines Printing the numbers 1 through 5, two ways without a loop PRINT 1 PRINT 2 PRINT 3 PRINT 4 PRINT 5 five lines for five numbers a million numbers needs a million lines with a loop FOR i = 1 TO 5: PRINT i END FOR three lines for five numbers a million numbers still needs three lines change the 5 to a million and nothing else about the code changes

The next three topics in this series — discrete mathematics to formalize the logic these conditions rely on, debugging and testing to catch the inevitable mistakes in programs built from these six ingredients, and memory and program execution to see what actually happens to a variable's named box at the hardware level — all build directly on the vocabulary introduced here.

Take programming fundamentals further

Ask the copilot about this term, or have our engineers assess it against your process.