SlideShare a Scribd company logo
Introduction to Programming
Programming is the process of telling a computer what to do using a specific language it
understands. It helps us create software, apps, games, websites, and more!
1. Basic Model of Computation
At its core, a computer works like a machine that:
 Takes Input (from keyboard, mouse, files, etc.)
 Processes it using logic (calculations, decisions)
 Produces Output (on screen, in files, etc.)
This basic model is often described as:
arduino
CopyEdit
INPUT → PROCESS → OUTPUT
Example:
You enter two numbers → Computer adds them → It shows the result.
2. What is an Algorithm?
An algorithm is a step-by-step set of instructions to solve a problem.
Think of it like a recipe:
 Input: Ingredients
 Steps: Mixing, baking
 Output: Cake
Example Algorithm to add two numbers:
1. Start
2. Input two numbers A and B
3. Add A + B and store in SUM
4. Output SUM
5. End
3. What is a Flowchart?
A flowchart is a visual diagram that shows the steps of an algorithm using symbols and arrows.
✨Common Flowchart Symbols:
Symbol Shape Purpose
Oval Start/End
Diamond Decision (Yes/No)
Rectangle Process/Step
Parallelogram Input/Output
➡ Arrow Shows flow
Flowcharts help visualize how a program works before writing code.
4. What is a Programming Language?
A programming language is a special language used to write instructions for a computer.
Some Common Languages:
 Python – easy and beginner-friendly
 C/C++ – powerful and fast
 Java – commonly used for apps
 JavaScript – used in websites
Each language has its own rules (syntax), but all are used to write logic (algorithms).
⚙ 5. Compilation
Compilation is the process of converting your code (which humans understand) into machine
code (which computers understand).
 Source Code → Written by the programmer (e.g., in C)
 Compiler → Converts it into machine language (binary)
 Executable → File the computer can run
Some languages like Python use an interpreter instead of a compiler.
6. Testing and Debugging
After writing your code, you must check that it works properly.
 Testing: Run your program with different inputs to see if it gives correct results.
 Debugging: Finding and fixing errors (bugs) in your program.
There are 3 types of errors:
Type Meaning
Syntax Error Mistake in code structure (e.g., missing colon)
Logic Error Code runs, but gives wrong result
Runtime Error Error occurs while running (e.g., divide by zero)
7. Documentation
Documentation means writing clear explanations about:
 What the program does
 How it works
 How to use it
It helps others (and your future self) understand your code. Good documentation includes:
 Comments in the code
 User guides
 Design notes
Summary Table
Concept What It Means
Model of Computation Input → Process → Output
Algorithm Step-by-step instructions
Flowchart Visual way to show steps
Programming Language Used to write programs
Compilation Converts code into machine language
Testing Checking if program works
Debugging Fixing problems in code
Documentation Explaining what the program does
What is Pseudocode?
Pseudocode is like writing down the steps of a program in plain English. It’s not real code, but
it shows how the code should work. You don’t worry about exact syntax (like commas or
brackets), just the logic.
✅Why Use Pseudocode?
 Helps you plan your code before writing it
 Easy to understand, even if you don’t know a programming language yet
 Makes it easier to spot mistakes
 Helps you explain your program to others
✍ How to Write Pseudocode
Use simple steps and common keywords. Here's a quick guide:
Task Pseudocode Keyword
Task Pseudocode Keyword
Start or end BEGIN, END
Take user input INPUT
Show a message OUTPUT or DISPLAY
Set a variable SET or ASSIGN
Make a choice IF, THEN, ELSE
Repeat steps WHILE, FOR
Use another function CALL
Example:
plaintext
CopyEdit
BEGIN
INPUT number
IF number > 0 THEN
OUTPUT "Positive"
ELSE
OUTPUT "Not positive"
END
What is a Flowchart?
A flowchart is a picture that shows the steps in a program using shapes and arrows. It’s a visual
way to understand how a program works.
Common Flowchart Symbols
Symbol Shape Use
Start/End Oval Shows where the program starts or ends
Process Rectangle A step that does something (like a calculation)
Decision Diamond A question with yes/no answers
Input/Output Parallelogram For reading input or showing output
Arrow ➡ Line Shows the direction of steps
How to Use Flowcharts
1. Start with the "Start" symbol
2. Add steps (input, processing, decisions)
3. Use arrows to show the order
4. End with the "End" symbol
Example: Password Checker
Goal: Check if a password is:
 At least 8 characters long
 Contains at least one number
✅Valid Passwords:
 super123
 meandmy2dogs
❌Invalid Passwords:
 hello (too short)
 password (no number)
Pseudocode for Password Checker
plaintext
CopyEdit
BEGIN
INPUT password
SET length = 0
SET has_number = False
WHILE length < length of password
SET current = character at position length
INCREMENT length by 1
IF current is a number THEN
SET has_number = True
IF length >= 8 AND has_number is True THEN
OUTPUT "Valid Password"
ELSE
OUTPUT "Invalid Password"
END
Flowchart (Explanation)
1. Start
2. Input the password
3. Check each character:
o Count the length
o Check if it’s a number
4. After checking:
o If length ≥ 8 AND there is a number → Valid
o Else → Invalid
5. End
Why Use Both Pseudocode & Flowcharts?
Using both gives you:
 Text view (pseudocode) for programmers
 Visual view (flowchart) for better understanding
 Helps in team projects, planning, and learning
❓ FAQs - Quick Answers
Q: Is pseudocode real code?
A: No, it's a way to describe code in plain English.
Q: Who uses pseudocode?
A: Students, programmers, teachers — anyone planning or learning code.
Q: What’s the difference between an algorithm and a flowchart?
A: An algorithm is a list of steps; a flowchart shows those steps as a picture.
Q: Is pseudocode hard?
A: Not at all! If you can explain what a program should do in plain words, you can write
pseudocode.
Flowchart Symbols (Basics)
Symbol Shape Meaning
Symbol Shape Meaning
Start/End Oval Marks where the flow starts or ends
Input/Output Parallelogram Reads or displays data
Process Rectangle A calculation or assignment
Decision Diamond A Yes/No (True/False) condition
Arrow ➡ Line Shows the flow from step to step
Types of Algorithm/Flowchart Processing
1. Sequential Processing
 Steps are done one after another in order.
2. Decision-Based Processing
 The program chooses a path based on a condition (like if-else).
3. Iterative Processing
 Loops are used to repeat steps (like for, while).
Basic Algorithm + Flowchart Examples
1. Exchanging Values of Two Variables
Algorithm:
1. Input A, B
2. Temp = A
3. A = B
4. B = Temp
5. Output A, B
Flowchart Keywords: Input → Process → Output
➕2. Summation of N Numbers
Algorithm:
1. Input N
2. Set Sum = 0
3. Repeat from i = 1 to N:
o Input number
o Sum = Sum + number
4. Output Sum
Flowchart Type: Iterative
3. Decimal to Binary Conversion
Algorithm:
1. Input decimal number n
2. While n > 0:
o Remainder = n % 2
o Store remainder
o n = n // 2
3. Print remainders in reverse order
Flowchart Type: Iterative + Stack logic (store remainders)
4. Reversing Digits of an Integer
Algorithm:
1. Input number n
2. Set reverse = 0
3. While n > 0:
o digit = n % 10
o reverse = reverse * 10 + digit
o n = n // 10
4. Output reverse
5. GCD of Two Numbers
Algorithm (Euclid’s Method):
1. Input A, B
2. While B ≠ 0:
o Temp = B
o B = A % B
o A = Temp
3. Output A (GCD)
6. Test if a Number is Prime
Algorithm:
1. Input number n
2. If n < 2 → Not Prime
3. Check if any number from 2 to √n divides n
o If yes → Not Prime
o Else → Prime
❗ 7. Factorial of a Number
Algorithm:
1. Input n
2. Set fact = 1
3. For i = 1 to n:
o fact = fact * i
4. Output fact
8. Fibonacci Sequence
Algorithm:
1. Input n
2. Set a = 0, b = 1
3. For i = 1 to n:
o Print a
o next = a + b
o a = b
o b = next
9. Evaluate sin(x) Using Series
Use the Taylor Series:
sin(x) = x - x³/3! + x⁵/5! - x⁷/7! + ...
Algorithm:
1. Input x, number of terms
2. Set sign = 1, sinx = 0, term = x
3. Repeat with increasing odd powers and alternating signs
4. Output sinx
10. Reverse Order of Elements in an Array
Algorithm:
1. Input array A[0...n-1]
2. Set start = 0, end = n-1
3. While start < end:
o Swap A[start] and A[end]
o start++, end--
4. Output array
11. Find Largest Number in an Array
Algorithm:
1. Input array A[0...n-1]
2. Set max = A[0]
3. For i = 1 to n-1:
o If A[i] > max → max = A[i]
4. Output max
12. Print Elements of Upper Triangular Matrix
For matrix A[i][j], upper triangle includes elements where i ≤ j
Algorithm:
1. Input matrix A[n][n]
2. For i = 0 to n-1:
o For j = 0 to n-1:
 If i ≤ j → Print A[i][j]
 Else → Print 0
✅Summary Chart
Problem Type of Processing
Swap Two Numbers Sequential
Sum of Numbers Iterative
Decimal to Binary Iterative
Reverse Digits Iterative
GCD Iterative (with condition)
Prime Test Decision + Iterative
Factorial Iterative
Fibonacci Iterative
sin(x) Iterative
Reverse Array Iterative
Largest in Array Iterative + Decision
Upper Triangular Matrix Nested Iteration + Condition

More Related Content

PPT
3 algorithm-and-flowchart
PPTX
INTROTOPROBLEMSOLVING.pptxINTROTOPROBLEMSOLVING.pptx
PPSX
Algorithm and flowchart
PPTX
s-INTRODUCTION TO PROBLEM SOLVING PPT.pptx
PPT
UNIT- 3-FOC.ppt
PPT
Proble, Solving & Automation
PPT
programming language(C++) chapter-one contd.ppt
PDF
Unit 1-problem solving with algorithm
3 algorithm-and-flowchart
INTROTOPROBLEMSOLVING.pptxINTROTOPROBLEMSOLVING.pptx
Algorithm and flowchart
s-INTRODUCTION TO PROBLEM SOLVING PPT.pptx
UNIT- 3-FOC.ppt
Proble, Solving & Automation
programming language(C++) chapter-one contd.ppt
Unit 1-problem solving with algorithm

Similar to Introduction to programming : flowchart, algorithm (20)

PPTX
MODULE1-INTRODUCTION.pptx-COMPUTER PROGRAMING
PPTX
Lec-ProblemSolving.pptx
PPTX
Unit 1 c programming language Tut and notes
PDF
Cse115 lecture03problemsolving
PPTX
Data Structures_Introduction to algorithms.pptx
PPT
Fundamentals of Programming Chapter 3
PPTX
Cs1123 2 comp_prog
DOCX
programming concept
PPTX
Introduction to problem solving Techniques
PDF
2021 CSE031.Lecture 6.Flow_Charts_Pseudocode.pptx.pdf
PPTX
Programming C ppt for learning foundations
PPTX
Pj01 1-computer and programming fundamentals
PPTX
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
PPT
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
PDF
Algorithmic problem sloving
PPT
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
PPTX
UNIT 1.pptx
PPTX
Algorithm and pseudo codes
PDF
Algorithm.pdf
PDF
ALGORITHMS AND FLOWCHARTS
MODULE1-INTRODUCTION.pptx-COMPUTER PROGRAMING
Lec-ProblemSolving.pptx
Unit 1 c programming language Tut and notes
Cse115 lecture03problemsolving
Data Structures_Introduction to algorithms.pptx
Fundamentals of Programming Chapter 3
Cs1123 2 comp_prog
programming concept
Introduction to problem solving Techniques
2021 CSE031.Lecture 6.Flow_Charts_Pseudocode.pptx.pdf
Programming C ppt for learning foundations
Pj01 1-computer and programming fundamentals
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Algorithmic problem sloving
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
UNIT 1.pptx
Algorithm and pseudo codes
Algorithm.pdf
ALGORITHMS AND FLOWCHARTS
Ad

More from Kritika Chauhan (19)

PPTX
Dalai Lama Succession Explained | History, Politics & China’s Role
PPTX
Introduction to Python — great for beginners or as a refresher.
PDF
Arduino MCQ Collection: Types, Memory, Applications, and Real-World Uses | Te...
PPTX
Group Captain Shubhanshu Shukla: India’s Return to Space After 41 Years | Ax-...
PDF
50+ Arduino MCQs with Answers | Beginners to Advanced Quiz for Electronics & IoT
PDF
MCQ INTERNET OF THINGS ARDUINO PROGREAMS - EMBEDDED C TYPES OF ARDUINO
DOCX
Write a NumPy program to find the most frequent value in an array. Take two...
PDF
skills-Personality Development Multiple Choice Questions
PPTX
Introduction to Arduino Its components & pins
PDF
Embedded C Programming O Level, C Level students, and diploma holder
PPTX
Introduction to Libre (Beginner Guide) .pptx
PPTX
Presentationonlinebusiness
PPTX
Successpptori
PPTX
Basics Of computer
PPTX
Operator of C language
PPTX
computer types
PPTX
cmd commands project
PPTX
Ppt of blogs
DOCX
Project report on blogs
Dalai Lama Succession Explained | History, Politics & China’s Role
Introduction to Python — great for beginners or as a refresher.
Arduino MCQ Collection: Types, Memory, Applications, and Real-World Uses | Te...
Group Captain Shubhanshu Shukla: India’s Return to Space After 41 Years | Ax-...
50+ Arduino MCQs with Answers | Beginners to Advanced Quiz for Electronics & IoT
MCQ INTERNET OF THINGS ARDUINO PROGREAMS - EMBEDDED C TYPES OF ARDUINO
Write a NumPy program to find the most frequent value in an array. Take two...
skills-Personality Development Multiple Choice Questions
Introduction to Arduino Its components & pins
Embedded C Programming O Level, C Level students, and diploma holder
Introduction to Libre (Beginner Guide) .pptx
Presentationonlinebusiness
Successpptori
Basics Of computer
Operator of C language
computer types
cmd commands project
Ppt of blogs
Project report on blogs
Ad

Recently uploaded (20)

PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Pre independence Education in Inndia.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Cell Structure & Organelles in detailed.
PDF
01-Introduction-to-Information-Management.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
O7-L3 Supply Chain Operations - ICLT Program
Abdominal Access Techniques with Prof. Dr. R K Mishra
TR - Agricultural Crops Production NC III.pdf
human mycosis Human fungal infections are called human mycosis..pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Open Quiz Monsoon Mind Game Prelims.pptx
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Pre independence Education in Inndia.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
102 student loan defaulters named and shamed – Is someone you know on the list?
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Microbial disease of the cardiovascular and lymphatic systems
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pharma ospi slides which help in ospi learning
Cell Structure & Organelles in detailed.
01-Introduction-to-Information-Management.pdf

Introduction to programming : flowchart, algorithm

  • 1. Introduction to Programming Programming is the process of telling a computer what to do using a specific language it understands. It helps us create software, apps, games, websites, and more! 1. Basic Model of Computation At its core, a computer works like a machine that:  Takes Input (from keyboard, mouse, files, etc.)  Processes it using logic (calculations, decisions)  Produces Output (on screen, in files, etc.) This basic model is often described as: arduino CopyEdit INPUT → PROCESS → OUTPUT Example: You enter two numbers → Computer adds them → It shows the result. 2. What is an Algorithm? An algorithm is a step-by-step set of instructions to solve a problem. Think of it like a recipe:  Input: Ingredients  Steps: Mixing, baking  Output: Cake Example Algorithm to add two numbers: 1. Start 2. Input two numbers A and B 3. Add A + B and store in SUM 4. Output SUM 5. End
  • 2. 3. What is a Flowchart? A flowchart is a visual diagram that shows the steps of an algorithm using symbols and arrows. ✨Common Flowchart Symbols: Symbol Shape Purpose Oval Start/End Diamond Decision (Yes/No) Rectangle Process/Step Parallelogram Input/Output ➡ Arrow Shows flow Flowcharts help visualize how a program works before writing code. 4. What is a Programming Language? A programming language is a special language used to write instructions for a computer. Some Common Languages:  Python – easy and beginner-friendly  C/C++ – powerful and fast  Java – commonly used for apps  JavaScript – used in websites Each language has its own rules (syntax), but all are used to write logic (algorithms). ⚙ 5. Compilation Compilation is the process of converting your code (which humans understand) into machine code (which computers understand).
  • 3.  Source Code → Written by the programmer (e.g., in C)  Compiler → Converts it into machine language (binary)  Executable → File the computer can run Some languages like Python use an interpreter instead of a compiler. 6. Testing and Debugging After writing your code, you must check that it works properly.  Testing: Run your program with different inputs to see if it gives correct results.  Debugging: Finding and fixing errors (bugs) in your program. There are 3 types of errors: Type Meaning Syntax Error Mistake in code structure (e.g., missing colon) Logic Error Code runs, but gives wrong result Runtime Error Error occurs while running (e.g., divide by zero) 7. Documentation Documentation means writing clear explanations about:  What the program does  How it works  How to use it It helps others (and your future self) understand your code. Good documentation includes:  Comments in the code  User guides  Design notes Summary Table
  • 4. Concept What It Means Model of Computation Input → Process → Output Algorithm Step-by-step instructions Flowchart Visual way to show steps Programming Language Used to write programs Compilation Converts code into machine language Testing Checking if program works Debugging Fixing problems in code Documentation Explaining what the program does What is Pseudocode? Pseudocode is like writing down the steps of a program in plain English. It’s not real code, but it shows how the code should work. You don’t worry about exact syntax (like commas or brackets), just the logic. ✅Why Use Pseudocode?  Helps you plan your code before writing it  Easy to understand, even if you don’t know a programming language yet  Makes it easier to spot mistakes  Helps you explain your program to others ✍ How to Write Pseudocode Use simple steps and common keywords. Here's a quick guide: Task Pseudocode Keyword
  • 5. Task Pseudocode Keyword Start or end BEGIN, END Take user input INPUT Show a message OUTPUT or DISPLAY Set a variable SET or ASSIGN Make a choice IF, THEN, ELSE Repeat steps WHILE, FOR Use another function CALL Example: plaintext CopyEdit BEGIN INPUT number IF number > 0 THEN OUTPUT "Positive" ELSE OUTPUT "Not positive" END What is a Flowchart? A flowchart is a picture that shows the steps in a program using shapes and arrows. It’s a visual way to understand how a program works. Common Flowchart Symbols Symbol Shape Use Start/End Oval Shows where the program starts or ends Process Rectangle A step that does something (like a calculation) Decision Diamond A question with yes/no answers Input/Output Parallelogram For reading input or showing output Arrow ➡ Line Shows the direction of steps How to Use Flowcharts 1. Start with the "Start" symbol 2. Add steps (input, processing, decisions)
  • 6. 3. Use arrows to show the order 4. End with the "End" symbol Example: Password Checker Goal: Check if a password is:  At least 8 characters long  Contains at least one number ✅Valid Passwords:  super123  meandmy2dogs ❌Invalid Passwords:  hello (too short)  password (no number) Pseudocode for Password Checker plaintext CopyEdit BEGIN INPUT password SET length = 0 SET has_number = False WHILE length < length of password SET current = character at position length INCREMENT length by 1 IF current is a number THEN SET has_number = True IF length >= 8 AND has_number is True THEN OUTPUT "Valid Password" ELSE OUTPUT "Invalid Password" END Flowchart (Explanation)
  • 7. 1. Start 2. Input the password 3. Check each character: o Count the length o Check if it’s a number 4. After checking: o If length ≥ 8 AND there is a number → Valid o Else → Invalid 5. End Why Use Both Pseudocode & Flowcharts? Using both gives you:  Text view (pseudocode) for programmers  Visual view (flowchart) for better understanding  Helps in team projects, planning, and learning ❓ FAQs - Quick Answers Q: Is pseudocode real code? A: No, it's a way to describe code in plain English. Q: Who uses pseudocode? A: Students, programmers, teachers — anyone planning or learning code. Q: What’s the difference between an algorithm and a flowchart? A: An algorithm is a list of steps; a flowchart shows those steps as a picture. Q: Is pseudocode hard? A: Not at all! If you can explain what a program should do in plain words, you can write pseudocode. Flowchart Symbols (Basics) Symbol Shape Meaning
  • 8. Symbol Shape Meaning Start/End Oval Marks where the flow starts or ends Input/Output Parallelogram Reads or displays data Process Rectangle A calculation or assignment Decision Diamond A Yes/No (True/False) condition Arrow ➡ Line Shows the flow from step to step Types of Algorithm/Flowchart Processing 1. Sequential Processing  Steps are done one after another in order. 2. Decision-Based Processing  The program chooses a path based on a condition (like if-else). 3. Iterative Processing  Loops are used to repeat steps (like for, while). Basic Algorithm + Flowchart Examples 1. Exchanging Values of Two Variables Algorithm: 1. Input A, B 2. Temp = A 3. A = B 4. B = Temp 5. Output A, B Flowchart Keywords: Input → Process → Output ➕2. Summation of N Numbers
  • 9. Algorithm: 1. Input N 2. Set Sum = 0 3. Repeat from i = 1 to N: o Input number o Sum = Sum + number 4. Output Sum Flowchart Type: Iterative 3. Decimal to Binary Conversion Algorithm: 1. Input decimal number n 2. While n > 0: o Remainder = n % 2 o Store remainder o n = n // 2 3. Print remainders in reverse order Flowchart Type: Iterative + Stack logic (store remainders) 4. Reversing Digits of an Integer Algorithm: 1. Input number n 2. Set reverse = 0 3. While n > 0: o digit = n % 10 o reverse = reverse * 10 + digit o n = n // 10 4. Output reverse 5. GCD of Two Numbers Algorithm (Euclid’s Method):
  • 10. 1. Input A, B 2. While B ≠ 0: o Temp = B o B = A % B o A = Temp 3. Output A (GCD) 6. Test if a Number is Prime Algorithm: 1. Input number n 2. If n < 2 → Not Prime 3. Check if any number from 2 to √n divides n o If yes → Not Prime o Else → Prime ❗ 7. Factorial of a Number Algorithm: 1. Input n 2. Set fact = 1 3. For i = 1 to n: o fact = fact * i 4. Output fact 8. Fibonacci Sequence Algorithm: 1. Input n 2. Set a = 0, b = 1 3. For i = 1 to n: o Print a o next = a + b o a = b o b = next
  • 11. 9. Evaluate sin(x) Using Series Use the Taylor Series: sin(x) = x - x³/3! + x⁵/5! - x⁷/7! + ... Algorithm: 1. Input x, number of terms 2. Set sign = 1, sinx = 0, term = x 3. Repeat with increasing odd powers and alternating signs 4. Output sinx 10. Reverse Order of Elements in an Array Algorithm: 1. Input array A[0...n-1] 2. Set start = 0, end = n-1 3. While start < end: o Swap A[start] and A[end] o start++, end-- 4. Output array 11. Find Largest Number in an Array Algorithm: 1. Input array A[0...n-1] 2. Set max = A[0] 3. For i = 1 to n-1: o If A[i] > max → max = A[i] 4. Output max 12. Print Elements of Upper Triangular Matrix For matrix A[i][j], upper triangle includes elements where i ≤ j Algorithm: 1. Input matrix A[n][n]
  • 12. 2. For i = 0 to n-1: o For j = 0 to n-1:  If i ≤ j → Print A[i][j]  Else → Print 0 ✅Summary Chart Problem Type of Processing Swap Two Numbers Sequential Sum of Numbers Iterative Decimal to Binary Iterative Reverse Digits Iterative GCD Iterative (with condition) Prime Test Decision + Iterative Factorial Iterative Fibonacci Iterative sin(x) Iterative Reverse Array Iterative Largest in Array Iterative + Decision Upper Triangular Matrix Nested Iteration + Condition