What is Computer

Module: M1-R5: Information Technology Tools and Network Basics

Chapter: Ch1 Computer Intro

🔹 Flowchart Example: Finding GCD (Greatest Common Divisor)

The Greatest Common Divisor (GCD) of two numbers is the largest number that divides both without leaving a remainder. The algorithm below uses the **Euclidean method** to find the GCD of two integers.

🧭 Algorithm Steps
  1. Start
  2. Input two numbers A and B
  3. Check if B = 0
  4. If yes, GCD = A → Go to End
  5. If no, set A = B and B = A % B
  6. Repeat step 3 until B becomes 0
  7. Stop
💠 Flowchart Diagram
Start
⬇️
Input A, B
⬇️
Is B = 0?
⬇️
GCD = A
⬇️
End
⬆️
Temp = A % B
A = B
B = Temp
💻 Python Code Example
# Program to find GCD of two numbers
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))

while b != 0:
    a, b = b, a % b

print("GCD is:", a)

✅ This code keeps dividing the numbers until b becomes zero. The final value of a is the GCD.

📘 Notes
  • Flowcharts help visualize how the algorithm progresses step-by-step.
  • Decision symbols (diamonds) are used to handle conditions like Is B = 0?.
  • Loops are represented using arrows that connect back to a previous decision point.
Quick Links