Algorithm:
An algorithm is a step-by-step procedure to solve a problem or perform a task. Its key
characteristics are:
1. Finiteness
o An algorithm must always terminate after a finite number of steps.
o It cannot go on indefinitely.
2. Definiteness
o Each step of an algorithm must be precisely and unambiguously defined.
o There should be no confusion about what action to perform.
3. Input
o An algorithm may have zero or more inputs.
o These are the values given to the algorithm to work upon.
4. Output
o An algorithm must produce at least one output.
o The output is the solution or result of the problem.
5. Effectiveness
o Every step of an algorithm must be simple enough to be performed exactly
and in finite time.
6. Generality
o An algorithm should solve all instances of a problem, not just a single case.
7. Language Independence
o Algorithms can be implemented in any programming language; they are not
tied to a specific language.
Example-1:
Problem: Find the sum of two numbers.
Algorithm:
1. Start.
2. Read two numbers, A and B.
3. Add A and B and store the result in SUM.
4. Display SUM.
5. Stop.
Problem-2: Find the largest of three numbers
Algorithm:
1. Start.
2. Read three numbers: A, B, and C.
3. If A > B and A > C, then
o Largest = A
Else if B > C, then
o Largest = B
Else
o Largest = C
4. Display Largest.
5. Stop.
Problem-3: Check whether a number is even or odd
Algorithm:
1. Start.
2. Read a number, N.
3. Divide N by 2 and find the remainder.
4. If remainder = 0, then
o Display “N is even.”
Else
o Display “N is odd.”
5. Stop.
Problem-4: Find the sum of first N natural numbers
Algorithm:
1. Start.
2. Read a number, N.
3. Initialize SUM = 0 and COUNTER = 1.
4. While COUNTER ≤ N, do:
o SUM = SUM + COUNTER
o COUNTER = COUNTER + 1
5. Display SUM.
6. Stop.
Problem-5: Find the factorial of a number (N!)
Algorithm:
1. Start.
2. Read a number, N.
3. Initialize FACTORIAL = 1 and COUNTER = 1.
4. While COUNTER ≤ N, do:
o FACTORIAL = FACTORIAL × COUNTER
o COUNTER = COUNTER + 1
5. Display FACTORIAL.
6. Stop.
Definition of Flowchart
A flowchart is a diagrammatic representation of an algorithm, process, or workflow.
• It uses standard symbols to show the sequence of steps.
• Helps in visualizing logic, understanding processes, and debugging errors.
Common Flowchart Symbols
Symbol Name Purpose / Usage
Oval / Ellipse Start / Stop Represents the start or end of a process.
Rectangle Process / Task Represents instructions or operations.
Parallelogram Input / Output Represents inputting data or displaying output.
Diamond Decision Represents a decision or condition (Yes/No).
Arrow Flow Line Shows the direction of flow from one step to another.
Example:
Check Even or Odd
Biggest of given 3
numbers