Why C, and What a Program Really Is
What Programming Really Is
In this lesson
- Say what a program is, in one sentence, to anyone who asks.
- Name the three moves (sequence, selection, repetition) inside an everyday task.
- Write a five step plan in plain English for a small problem.
A recipe card for biryani cooks nothing. It has no heat, no rice, no onions. All it holds is a list of steps, written carefully enough that a patient stranger can follow them.
Programming is writing that kind of card for a machine. The machine is very patient. It is also the worst cook you will ever meet. It will not add salt unless the card says so.
Maria and Bob are arguing about this over a plate of samosas. Bob says the hard part of programming is the typing. Maria asks him to explain, out loud, how to find the largest of five numbers. Bob says, "look at them and pick the biggest one".
Maria says that is not an instruction. A machine cannot look at five numbers at once. It can compare two, remember one, and move on. Bob goes quiet, which is how most people start learning to program.
The computer is fast, not smart
A modern processor runs billions of small instructions every second. It will add two ten digit numbers before you finish blinking. And it cannot work out that nmae was meant to be name.
That combination is the whole personality of the machine. It has enormous speed and no common sense at all. When you write a program you are not explaining an idea. You are giving orders that leave nothing out.
This feels unfair for about two weeks. Then it becomes the best news in the subject. A machine with no imagination cannot surprise you. If your program is wrong, it is wrong because of something you wrote. Something you wrote can be found and fixed.
Note
A bug is the ordinary word for a mistake in a program. Every working programmer writes them daily. The skill is not avoiding bugs forever. The skill is finding them calmly.
Exact orders: data, steps, output
Every order you give a machine answers three questions.
- What data do I keep? These are the ingredients: five numbers, a name, a temperature.
- What do I do with it, and in what order? These are the steps.
- What do I show at the end? This is the dish on the table.
Miss one of the three and the machine does not fill the gap. It either stops with an error, or it hands you a confident wrong answer. The second outcome is the dangerous one.
So here is a useful test for any step you write. Could a stranger carry it out, the same way, every time? If the answer is no, the step is still a wish, not an instruction.
The three moves: sequence, selection, repetition
Strip away the vocabulary and every program ever written is built from three moves.
| Move | What it means | In the kitchen | In a program |
|---|---|---|---|
| Sequence | Do this, then this, then this | Boil water, add rice, drain | Read a number, double it, print it |
| Selection | If something is true do A, otherwise do B | If guests are coming, cook double | If the mark is below 40, print "fail" |
| Repetition | Keep doing this until something changes | Keep stirring until it thickens | Keep reading numbers until the list ends |
That is the entire toolkit. You will spend the rest of this track learning to write each move in C. You will spend the rest of your career mixing them in more interesting ways. So when you read a program later and it looks like a wall of symbols, find the three moves first. They are always there.
Input, processing, output
The three moves describe what happens inside. The shape around the outside is simpler still: something goes in, something happens to it, something comes out.
Once you see this shape you see it everywhere. Your phone's alarm takes a time as input, compares it to the clock, and rings. A search box takes words, finds matching pages, and lists them. Nothing else is going on.
A plan is not magic
Beginners often think experienced programmers know a secret. They do not. What they have is a habit: turning a fuzzy goal into small, checkable steps. The habit can be trained. Training it is what this whole track is for.
So here are three plans, written in plain English, before any C. Read each one and ask the stranger question: could someone follow this without guessing?
This is the plan Bob could not say out loud. Notice that the machine only ever compares two things.
- Take the first number. Call it largest so far.
- Take the next number in the list.
- If that number is bigger than largest so far, make it the new largest so far.
- Repeat steps 2 and 3 until the list runs out.
- Report largest so far. That is the answer.
Numbers: 12 40 7 40 3
Step 1: largest so far = 12
Step 2: 40 > 12, largest so far = 40
Step 3: 7 is not bigger, no change
Step 4: 40 is not bigger, no change
Step 5: 3 is not bigger, no change
Answer: 40
All three moves are here. Steps 1 and 5 are sequence, step 3 is selection, step 4 is repetition. A plan this size is what you will write in C in Module 9.
A palindrome reads the same forwards and backwards, like madam. A machine cannot see the whole word at once. It can look at one letter at a time and count positions.
- Point at the first letter and at the last letter.
- If the two letters are different, report "no" and stop.
- If they are the same, move the first pointer one step right and the last pointer one step left.
- Repeat steps 2 and 3 while the first pointer is still before the last.
- If you run out of letters without reporting "no", report "yes".
Word: madam
m and m match, move inwards
a and a match, move inwards
pointers meet at d, nothing left to check
Answer: yes
Step 2 stops early on the first mismatch. That is a real design decision, not an accident. Zara would point out the two cases worth checking: an empty word, and a word of one letter.
The same three moves scale up to money. Here is the plan behind a mobile transfer, with the checks kept in.
- Read the receiver's number, the amount and the PIN.
- If the PIN is wrong, report "wrong PIN" and stop.
- If the amount is more than the balance, report "not enough money" and stop.
- Subtract the amount from the sender, add it to the receiver, write one line in the log.
- Show a confirmation with the new balance.
Balance: 500. Amount: 700.
PIN check: passed
Balance check: 700 > 500
Answer: not enough money
Steps 2 and 3 are selections that stop the program early. Real systems are mostly made of steps like these. The interesting part of the work is deciding which checks belong, and in what order.
Tip
For the next week, when an app does something, pause and name its three parts. What went in? What did it compute? What came out?
Ten seconds each time. This habit builds the programmer's eye faster than any amount of reading.
Where this is used
- bc, the calculator that ships with Linux and macOS. Input is the expression you type. Processing is one pass over your arithmetic. Output is the number. Its repetition move is the loop that keeps reading until you quit.
- An ATM cash withdrawal. Input is your card, PIN and amount. The selection moves are the PIN check and the balance check. The bank's answer travels as an ISO 8583 message, a format from 1987 that is still in daily use.
- Wikipedia's search box. Input is your words. Processing is CirrusSearch, the Elasticsearch based engine Wikipedia has run since 2014. Output is the ranked list. The repetition move runs once per candidate page.
- A traffic light controller. Input is the timer and the road sensors. Selection picks the next phase, repetition runs the cycle forever, and output is which lamp is lit. The behaviour is set by the NEMA TS-2 standard in the United States.
Common mistakes
1. A step that asks the machine to "look" or "notice".
Bob writes: "Look at the five numbers and take the biggest." Nothing happens, because there is no such instruction. A machine compares two values; it never scans a group at a glance. The fix is Plan 1 above: keep a largest so far and compare one number at a time.
2. Forgetting to say where the answer goes.
A plan that ends with "and that is the largest" has no output step. The program computes the right answer and shows nothing. You will meet the C version of this in Module 3, where the fix is one line: print it.
3. A repetition with no way to stop.
"Keep comparing numbers" never ends. The real machine does not stop politely; it spins until you kill it. Every repetition step needs the word until and something that actually changes. In Plan 1 that something is your position in the list.
4. Two steps that secretly depend on order.
Swap steps 3 and 4 in Plan 3 and the app takes the money before checking the balance. Both versions "work" on a happy day. Only one of them is correct. Order is part of the meaning, not decoration.
On paper, write the plan for finding the largest of five numbers in your own words. Do not look at Plan 1. Then check it against the stranger test, and mark any step a person would have to guess at.
Rules. No code. Five steps or fewer. No step may use the words "look", "see", "notice" or "obviously". Every step must mention at most two numbers at a time.
Check yourself. Run your plan by hand on the list 3, 3, 3, 3, 3. Then run it on 9, 1, 1, 1, 1. A correct plan answers 3 and then 9, without a special case for either.
Write the plan for deciding whether a year is a leap year. You will write this as real C in Module 5, so a good plan now saves you time later.
The rule. A year is a leap year if it divides by 4. Years dividing by 100 are an exception and are not leap years. Years dividing by 400 are an exception to that exception, and are leap years. So 2024 is a leap year, 1900 is not, and 2000 is.
Rules. Plain English. Use the word "if" for every selection. Your plan must give the right answer for all four of 2024, 1900, 2000 and 2023.
Check yourself. Most first attempts get 1900 wrong. If yours does, the order of your "if" steps is the thing to change.
Write the plan for counting the words in a sentence. A word is a run of letters. Words are separated by one or more spaces.
Rules. The machine reads one character at a time, left to right, and cannot go back. It may keep a count and one yes or no fact. That is all the memory you get.
Check yourself. Your plan must answer 3 for the quick fox and 3 for the quick fox with extra spaces. It must answer 0 for an empty line, and 1 for hello with leading spaces. Zara would test the last two first.
Common doubts
Do I need to be good at mathematics to program?
No. You need to be comfortable being precise, which is a different thing. Most programs use arithmetic you already learned by age twelve. Some fields, like graphics and machine learning, need more. Ordinary software needs care, not calculus.
Why write plans on paper when I could just type code?
Because typing hides the hard part. A wrong plan in C looks like a syntax problem and sends you hunting in the wrong place. A wrong plan in English is obvious in ten seconds. Experienced programmers still sketch before they type, usually in four or five lines.
Is an algorithm the same thing as a program?
An algorithm is the plan. A program is that plan written in a language a machine can run. The same algorithm can become a C program, a Python program and a page in a notebook. Plan 1 above is an algorithm; you have not written a program yet.
How long until I can build something real?
You will run your first C program in Module 1 and write your own in Module 2. Something a friend would actually use takes a few months of steady practice. The honest answer is that the first two weeks feel slow and then the speed changes.
Everyone around me seems to get this faster. Is that a bad sign?
No, and the comparison is usually wrong. People who look fast have almost always typed this before. The only measure that predicts anything is whether you finish the exercises, including the ones that annoy you.
Key takeaways
- A program is a list of exact instructions a machine follows one step at a time.
- The machine is fast and literal. It does what you wrote, never what you meant.
- Every program is built from three moves: sequence, selection and repetition.
- Every program has the same outer shape: input, processing, output.
- A step a stranger would have to guess at is a wish, not an instruction.
- An algorithm is the plan; a program is that plan written in a language.
Next you will meet the question everyone asks in 2026. If an assistant can write C for you, why learn it yourself? The answer is more interesting than either side of that argument.
Keyboard: j for the next lesson, k for the previous one, r to open the editor.