Algorithm's Notes
1. What is an Algorithm?
An algorithm is a step-by-step procedure to solve a problem in a logical and finite way.
Simple words:
Algorithm = clear steps jo problem ko solve kare
2. Key Characteristics of an Algorithm
Finite → Must end after some steps
Definite → Steps must be clear
Input → Takes input
Output → Produces result
Effective → Steps are simple
3. Basic Structure of an Algorithm
Start → Input → Process → Output → End
4. Real Life Examples
Example 1: Making Tea
Start → Take water → Boil → Add tea → Add milk & sugar → Boil → Pour → End
Example 2: ATM Withdrawal
Start → Insert card → Enter PIN → Check → Enter amount → Check balance → Dispense cash
→ End
Conditional Statements
1. if Statement
Runs only if condition is true
2. if-else Statement
Two choices: true or false
3. else-if Statement
Multiple conditions checked one by one
Problems
Even or Odd
Largest of Two Numbers
Average of 4 Subjects
Positive/Negative/Zero
Biggest of 3 Numbers
Loop Example
Print numbers from 1 to 5 using loop
Advantages
Easy, Step-by-step, Language independent, Debugging help
Disadvantages
Time consuming, Not visual, Lengthy
Applications
Software, Apps, Websites, Banking, AI