02-08-2024
02-08-2024
1
Algorithm
2
Algorithm
✔ Sequence Statements:
✔ In this program, all the instructions are executed one after another
✔ Example: Algorithm to print “Welcome to SMEC, VIT Chennai”
Step-1: Start
Step-2: Print “Welcome to SMEC, VIT Chennai
Step-3: Stop
3
Algorithm
✔ Sequence Statements:
✔ In this program, all the instructions are executed one after another
✔ Example: Algorithm to find area of a rectangle”
Step-1: Start
Step-2: Take length and breadth and store them
as L and B
Step-3: Multiply by L and B and store it in Area
Step-4: Print Area
Step-5: Stop
4
Algorithm
5
Algorithm
6
Algorithm
7
Flowchart
Connector
Decision Box
Diamond
Flow of Control
8
Flowchart
✔ Examples:
Simple Interest Calculation Bigger Number among Two
Numbers
P-principal
R-interest rate
T- time duration
9
Flowchart
✔ Examples:
Total Sales Calculation
START A
READ PRINT
QUANTITY TOTALSALE
A STOP
10
Flowchart
✔ Examples:
Average of Three Numbers
11
Flowchart
✔ Examples:
Factorial of N
12
Pseudo Code
13
Pseudo Code
14
Pseudo Code
Keywords
✔ Several keywords are often used to indicate common input, output, and
processing operations
✔ Input: READ, OBTAIN, GET
✔ Output: PRINT, DISPLAY, SHOW
✔ Compute: COMPUTE, CALCULATE, DETERMINE
✔ Initialize: SET, INIT
✔ Add one: INCREMENT, BUMP
15
Pseudo Code
Example Sequential
✔ Area of Rectangle Calculation
16
Pseudo Code
17
Pseudo Code
WHILE
✔ Format
Example:
WHILE Condition WHILE Population < Limit
Statements Compute Population as Population +
ENDWHILE Births ‐ Deaths
ENDWHILE
18
Pseudo Code
FOR
✔ Format
Example:
FOR Iteration Bounds FOR each student in the list
Statements Print Register_Number
ENDFOR ENDFOR
19
Rules for Variable Names
20
Exercises
Write the PAC, Algorithm, Pseudo code and draw the Flowchart for the
following cases
✔ Find the area of a circle
✔ Find the area of triangles where three sides are given
✔ Find the area and perimeter of a square
✔ Calculate the average for 3 numbers
✔ Find the greatest of three numbers
✔ Interchange the value of two numbers
✔ Calculate the simple interest
✔ Convert m3 to litre
22
Exercises
Write the PAC, Algorithm, Pseudo code and draw the Flowchart for the
following cases
✔ Find the sum of ‘n’ natural numbers
✔ Find the sum of all even numbers up to ‘n’
✔ Find out whether the given number is even or odd
✔ Find the sum of multiples of 8 up to the given number
✔ Print the numbers from 1 to ‘n’ in reverse order
✔ Find the average marks of 5 subjects of a student
✔ Convert the numeric grade to letter grade
23