3.Algorithm and Flowchart

Introduction
Before writing any program in C or any other language, it is important to understand how to think and plan a solution.
This planning is done using algorithms and flowcharts.
In Programming by Problem Solving, algorithms and flowcharts help students convert a problem into a step-by-step logical solution before coding.
What Is an Algorithm?
An algorithm is a finite set of clear and unambiguous steps used to solve a problem.
In simple words:
An algorithm is a step-by-step method to solve a problem.
Example (Real life)
Problem: Making tea
Algorithm:
Start
Boil water
Add tea leaves and sugar
Add milk
Boil for some time
Serve tea
Stop
This shows that an algorithm is not only for programming, but also for daily activities.
Algorithm: Addition of Two Numbers
Step 1: Start
Step 2: Input two numbers A and B
Step 3: Add A and B and store the result in SUM
Step 4: Print SUM
Step 5: Stop
Characteristics of an Algorithm
A good algorithm should have the following characteristics:
1️⃣ Input
An algorithm should have zero or more inputs.
These inputs are the data required to solve the problem.
2️⃣ Output
An algorithm must produce at least one output.
The output is the result obtained after processing the input.
3️⃣ Definiteness
Each step of the algorithm should be clear, precise, and unambiguous.
There should be no confusion in understanding any step.
4️⃣ Finiteness
An algorithm must terminate after a finite number of steps.
It should not run forever.
5️⃣ Effectiveness
All operations in the algorithm should be simple and executable.
Each step should be possible to perform in a finite time.
6️⃣ Generality
An algorithm should be applicable to a class of problems, not just one specific input.
What Is a Flowchart?
A flowchart is a graphical representation of an algorithm.
It uses symbols to show the flow of control from one step to another.
Flowcharts make it easier to:
Understand program logic
Detect errors early
Explain the solution clearly
Common Flowchart Symbols

Flowchart for Addition of two numbers

Difference Between Algorithm and Flowchart
| Algorithm | Flowchart |
| Written in steps | Drawn using symbols |
| Easy to write | Easy to understand visually |
| Text-based | Diagram-based |
| Used before flowchart | Based on algorithm |




