Resources | Subject Notes | Computer Science
This section focuses on developing and representing solutions to problems using flowcharts, structure diagrams, and pseudocode. These tools help in planning and documenting algorithms before implementation.
Flowcharts are visual representations of algorithms, using standard symbols to depict different steps and decisions.
Symbol | Name |
---|---|
Start/End | |
Process | |
Decision | |
Input/Output | |
Arrow |
Example: A simple flowchart for adding two numbers.
Structure diagrams are a way of representing the structure of a program, particularly using control structures like sequence, selection (if/else), and iteration (loops).
Type | Description |
---|---|
Sequence | Steps are executed in order. |
Selection (if/else) | Different blocks of code are executed based on a condition. |
Iteration (Loops) | Blocks of code are repeated until a condition is met. |
Example: A structure diagram for checking if a number is positive.
Pseudocode is a human-readable, informal description of an algorithm. It uses plain English and programming-like constructs to outline the steps of an algorithm.
Construct | Description | Example |
---|---|---|
Assign | Stores a value in a variable. | x = 5 |
Display | Shows output to the user. | DISPLAY "Hello" |
Input | Gets data from the user. | INPUT name |
If/Else | Executes different blocks of code based on a condition. |
IF age >= 18 THEN
DISPLAY "Eligible to vote"
ELSE
DISPLAY "Not eligible to vote"
ENDIF
|
Loop (Repeat Until/While) | Repeats a block of code until a condition is met. |
WHILE count < 10 DO
DISPLAY count
count = count + 1
ENDWHILE
|
Example: Pseudocode for calculating the area of a rectangle.
START INPUT length INPUT width area = length * width DISPLAY "The area is: " + area END