First Programs
Alright, so you are about to write your very first programs — exciting, right? But before we jump into building anything fancy, let's talk about what actually happens when you type some code and hit "run." Like, what is really going on behind the scenes?
Think of it this way: imagine you want to invent a brand new language — like an actual human language. What would you need? An alphabet, some grammar rules, a way to structure sentences, right? Programming languages work the same way. C is the language (with its own rules and grammar), and the compiler is the tool that checks if you followed those rules correctly and then translates everything into something the computer can actually understand — binary, the 1s and 0s.
This week, we are going to cover three big things. First, how your code becomes a program — you write a text file, a tool called a compiler translates it, and boom, you have something that runs. Second, variables and data types — think of these as labeled boxes where you stash your data (numbers, letters, decimals) while your program does its thing. Third, input and output — how your program talks to the user with printf and listens with scanf.
| Concept | What It Means | Why It Matters |
|---|---|---|
| Source Code | The .c file you write in C | It is your set of instructions in human-readable form |
| Compiler (gcc) | Translates source code to machine code | The computer cannot read C directly — it needs binary |
| Variable | A named box in memory that holds a value | Every program needs to store and manipulate data |
| Data Type | The kind of value a variable holds (int, float, char) | Tells the computer how much memory to reserve and how to interpret the bits |
| printf/scanf | Functions for output and input | How your program communicates with the user |