CSEC Information Technology:
Programming Study Notes
1. What is Programming?
Programming is the process of writing instructions (code) for a computer to perform tasks.
Programs are written in programming languages like Python, Java, and Pascal.
2. Programming Languages
- **Low-level languages**: Machine language, Assembly.
- **High-level languages**: Closer to human language; easier to read and write (e.g., Pascal,
Python, C).
Examples:
- Pascal: Often used in CSEC exams.
- Python: Widely used in modern applications.
3. Programming Terms
- **Algorithm**: A step-by-step plan to solve a problem.
- **Variable**: A named space in memory to store a value.
- **Constant**: A value that doesn’t change.
- **Data Types**: Integer, Real, Char, String, Boolean.
4. Control Structures
- **Sequence**: Instructions run one after the other.
- **Selection**: If…Then…Else statements used for decision-making.
- **Iteration**: Loops (For, While, Repeat…Until). Used for repeating tasks.
Example in Pascal:
```
If age > 18 Then
WriteLn('Adult')
Else
WriteLn('Minor');
```
5. Pseudocode and Flowcharts
- **Pseudocode**: Structured English to describe algorithms.
- **Flowcharts**: Diagrams that show the flow of an algorithm using shapes.
- Oval: Start/End
- Parallelogram: Input/Output
- Rectangle: Process
- Diamond: Decision
6. Basic Input/Output
Input allows users to enter data; Output displays results.
Pascal example:
```
Var name: String;
Begin
Write('Enter your name: ');
ReadLn(name);
WriteLn('Hello ', name);
End.
```
7. Arithmetic and Relational Operators
- **Arithmetic**: +, -, *, /, MOD, DIV
- **Relational**: =, <>, <, >, <=, >=
Used in conditions and calculations.
8. Arrays and Strings
- **Array**: A collection of elements of the same type.
- Example: `scores: array[1..5] of integer;`
- **String operations**: Length, Concatenation, Substring.
9. Debugging and Testing
- **Syntax errors**: Mistakes in code (e.g., missing semicolon).
- **Logic errors**: Code runs but produces incorrect results.
- **Testing**: Verifying that the program works as expected.
10. Writing Good Code
- Use comments to explain sections.
- Use meaningful variable names.
- Follow consistent indentation and formatting.