What is code?
- All code is conceptually the same:
- Save data.
- If something, then something.
- If–then lets us make decisions.
- We can remember data by saving it in named “boxes”—variables.
- Decision example: if the light is off, then turn it on.
- Memory example: save the number 5 in a box named “Johny.”
Example
- Store 1 in a box named light:
int light = 1; - If light equals 1, change it to 0:
if (light == 1) { light = 0; }
“int” is the type, or kind, of thing we put in the box. There can be many types. For example, a text character would be “char”.