Programming and Algorithms
Programming and Algorithms
8.1.2 Flowcharts
1
Rectangle: Indicates a process or instruction (e.g., calculation or
assignment).
Diamond: Represents a decision point (e.g., if-else conditions).
Parallelogram: Used for input and output operations (e.g., reading data or
displaying results).
Example: A flowchart for the algorithm to add two numbers would include shapes
representing each step, connecting them with arrows to show the flow from start
to finish.
8.2.1 Sequence
A=5
B = 10
C = A + B # C is now 15
print(C)
Characteristics:
8.2.2 Selection
2
Example
age = 18
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.")
Characteristics:
8.2.3 Iteration
count = 0
while count < 5: # Executes as long as count is less than 5
print(count)
count += 1 # Increments count by 1
Characteristics:
3
o Can lead to infinite loops if the termination condition is not defined
correctly.
8.3 Summary
https://zedicthub.blogspot.com/