Introduction to Programming and Algorithms
What this domain tests
This domain tests problem-solving before coding: writing algorithms, drawing flowcharts, and understanding how source code is translated and executed. Expect questions on algorithm properties, flowchart symbols, data types, operators, and expression evaluation.
Core rules
- An algorithm is a finite sequence of clear steps. It must have input, output, definiteness, finiteness, and effectiveness.
- Flowchart symbols: oval = start/stop; parallelogram = input/output; rectangle = process; diamond = decision; arrow = flow; circle = connector.
- Pseudocode is structured English-like notation, not tied to a language.
- A compiler translates the whole program before execution; an interpreter translates and executes line by line.
- Data types: int (whole numbers), float/double (real numbers), char (single character), bool (true/false), string (text).
- Operators: arithmetic (+ − * / %), relational (< > <= >= == !=), logical (AND, OR, NOT), assignment (=).
- Precedence: parentheses, then unary, then * / %, then + −, then relational, then logical, then assignment.
- Integer division discards the fractional part; % gives the remainder.
Worked example
Evaluate 7 + 3 * 2. Multiplication binds first: 3 * 2 = 6, then 7 + 6 = 13. With parentheses, (7 + 3) * 2 = 10 * 2 = 20. For 5 / 2 with integer operands, the result is 2, not 2.5; use 5.0 / 2 for 2.5. For 17 % 5, the remainder is 2 because 5 * 3 = 15 and 17 − 15 = 2.
Traps
- Writing = for comparison; use ==.
- Assuming / always produces a decimal when both operands are integers.
- Using an uninitialised variable, so its value is undefined.
- Confusing the decision diamond with the process rectangle.
- Treating a flowchart as a program; it is a design tool.