Computer Science · Chapter 8
Study notes aligned to the official NEB syllabus.
Languages fall into three levels. Machine language is pure binary, the only form a processor executes directly: fast to run, tedious to write. Assembly language replaces raw opcodes with mnemonics like MOV and ADD, symbolic addresses too, but is still processor-specific and needs an assembler. High-level languages (C, Python, Java) use English-like keywords, are hardware-independent, and need a compiler or interpreter.
| Feature | Machine | Assembly | High-level |
|---|---|---|---|
| Form | Binary | Mnemonics | English-like |
| Hardware dependence | Full | Full | Minimal |
| Translator needed | None | Assembler | Compiler/interpreter |
An assembler converts assembly source into machine code, one instruction at a time. A compiler reads the whole high-level program, checks it for errors, and translates it as one unit into an executable, so it runs fast and reports errors together after the full scan (C works this way). An interpreter translates and executes line by line with no separate executable, easier to test but slower, and it stops at the first error met (Python works this way).
A syntax error breaks the language's grammar (missing semicolon, unmatched brace), caught by the compiler before the program can run. A semantic (logical) error means the program compiles and runs but gives the wrong answer because the logic is flawed, for example + used where * was meant, the hardest kind to spot since the compiler sees nothing wrong. A runtime error appears only during execution, such as dividing by zero, despite clean compilation.
An algorithm is an ordered set of plain-language steps, for example finding the larger of a and b:
a and b. 3. If a > b, the larger is a; otherwise it is b. 4. Display the larger number. 5. Stop.A flowchart draws the same logic with standard symbols: oval (terminal) for start/end, rectangle (process) for a calculation, diamond (decision) for a branching condition, parallelogram (input/output) for reading or displaying data.
Pseudocode writes the same logic without committing to a real language's syntax:
BEGIN
READ a, b
IF a > b THEN
PRINT a, "is larger"
ELSE
PRINT b, "is larger"
ENDIF
END
Every program is built from sequence (statements run in order), selection (branching on a condition: if/if-else/switch), and iteration (repeating a block while a condition holds: for/while/do-while). Full C syntax follows later in this chapter.