A program is a precise set of instructions that a computer executes. Source code is human-readable text; the machine runs a translated form (interpreted line-by-line or compiled ahead of time).
Input, process, output
Most beginner programs follow IPO:
- Input — keyboard, files, sensors, HTTP requests.
- Process — calculations, decisions, loops, data transforms.
- Output — text on screen, files, API responses, HTML sent to a browser.
Syntax vs semantics
Syntax is whether tokens are valid (if (x < 0)). Semantics is what happens when it runs (does it handle negative numbers correctly?). Both matter in interviews and code review.
Self-check
- Give an example of input and output for a “hello name” CLI program.
- What is one syntax error and one logic (semantic) error?
Interview prep
- Why do small syntax errors sometimes cause big runtime failures?
Languages have strict grammars; a parser or runtime may misinterpret the rest of the file after a single invalid token, producing cascading errors that look worse than the root cause.
- What is the difference between syntax and semantics?
Syntax is whether tokens are valid. Semantics is what a valid program means when executed—two snippets can be syntactically valid but one be logically wrong.