algo_flowchart_examples
algo_flowchart_examples
The word “algorithm” relates to the name of the mathematician Al-khowarizmi, which means a
procedure or a technique. Software Engineer commonly uses an algorithm for planning and
solving the problems. An algorithm is a sequence of steps to solve a particular problem or
algorithm is an ordered set of unambiguous steps that produces a result and terminates in a
finite time
The algorithm and flowchart include following three types of control structures.
1. Sequence: In the sequence structure, statements are placed one after the other and
the execution takes place starting from up to down.
2. Branching (Selection): In branch control, there is a condition and according to a
condition, a decision of either TRUE or FALSE is achieved. In the case of TRUE, one
of the two branches is explored; but in the case of FALSE condition, the other
alternative is taken. Generally, the ‘IF-THEN’ is used to represent branch control.
3. Loop (Repetition): The Loop or Repetition allows a statement(s) to be executed
repeatedly based on certain loop condition e.g. WHILE, FOR loops.
Advantages of algorithm
1 CIC-UHF
Algorithm & Flowchart Manual
Step 2 Define the variables: Algorithm's variables allow you to use it for more than one
place. We can define two variables for rectangle height and rectangle width as HEIGHT and
WIDTH (or H & W). We should use meaningful variable name e.g. instead of using H & W
use HEIGHT and WIDTH as variable name.
Step 3 Outline the algorithm's operations: Use input variable for computation purpose,
e.g. to find area of rectangle multiply the HEIGHT and WIDTH variable and store the value in
new variable (say) AREA. An algorithm's operations can take the form of multiple steps and
even branch, depending on the value of the input variables.
Step 4 Output the results of your algorithm's operations: In case of area of rectangle
output will be the value stored in variable AREA. if the input variables described a rectangle
with a HEIGHT of 2 and a WIDTH of 3, the algorithm would output the value of 6.
FLOWCHART:
The first design of flowchart goes back to 1945 which was designed by John Von Neumann.
Unlike an algorithm, Flowchart uses different symbols to design a solution to a problem. It is
another commonly used programming tool. By looking at a Flowchartone can understand the
operations and sequence of operations performed in a system. Flowchart is often considered
as a blueprint of a design used for solving a specific problem.
Advantages of flowchart:
2 CIC-UHF
Algorithm & Flowchart Manual
Symbol Name Symbol function
Predefined Process
/Function Used to represent
a group of statements
performing one processing
task.
Preprocessor
|--------------
--------- | Comments
|--------------
The language used to write algorithm is simple and similar to day-to-day life language. The
variable names are used to store the values. The value store in variable can change in the
3 CIC-UHF
Algorithm & Flowchart Manual
solution steps. In addition some special symbols are used as below Assignment Symbol
HEIGHT 5
or
HEIGHT = 5
The symbol ‘=’ is used in most of the programming language as an assignment symbol, the
same has been used in all the algorithms and flowcharts in the manual.
The statement C = A + B means that add the value stored in variable A and variable B
then assign/store the value in variable C.
The statement R = R + 1 means that add I to the value stored in variable R and then
assign/store the new value in variable R, in other words increase the value of variable R by 1
Mathematical Operators:
Operator Meaning Example
+ Addition A+B
- Subtraction A–B
* Multiplication A*B
/ Division A/ B
^ Power A^3 for A3
% Reminder A%B
Relational Operators
Operator Meaning Example
< Less than A<B
<= Less than or equal to A <= B
= or == Equal to A = B
# or != Not equal to A # B or A !=B
> Greater than A>B
>= Greater tha or equal to A >= B
Logical Operators
Operator Example Meaning
AND A < B AND B < C Result is True if both A<B and
B<C are true else false
4 CIC-UHF
Algorithm & Flowchart Manual
OR A< B OR B < C Result is True if either A<B or
B<C are true else false
NOT NOT (A >B) Result is True if A>B is false
else true
Note: We can use keyword INPUT or READ or GET to accept input(s) /value(s) and
keywords PRINT or WRITE or DISPLAY to output the result(s). ..
5 CIC-UHF
Algorithm & Flowchart Manual
Algorithm
Step-1 Start
Step-4 SUM = A + B
Step-6 Stop
OR
Algorithm
Step-1 Start
Step-3 SUM = A + B
Step-5 Stop
6 CIC-UHF
Algorithm & Flowchart Manual
..
C : temperature in Celsius
F : temperature Fahrenheit
Algorithm
Step-1 Start
Step-3 F = (9.0/5.0 x C) + 32
Step-5 Stop
C : temperature in Celsius
F : temperature Fahrenheit
Algorithm
Step-1 Start
Step-3 C = 5.0/9.0 (F - 32 )
Step-5 Stop
7 CIC-UHF
Algorithm & Flowchart Manual
..
Algorithm
Step-1 Start
Step-3 Area = L x L
Step-4 PERIMETER = 4 x L
Step-6 Stop
L : Length of Rectangle
B : Breadth of Rectangle
AREA : Area of Rectangle
PERIMETER : Perimeter of Rectangle
Algorithm
Step-1 Start
Step-3 Area = L x B
Step-4 PERIMETER = 2 x ( L + B)
Step-6 Stop
8 CIC-UHF
Algorithm & Flowchart Manual
..
Step-1 Start
Stop
Algorithm
Step-1 Start
Step-5 PERIMETER = S1 + S2 + S3
Step-7 Stop
9 CIC-UHF
Algorithm & Flowchart Manual
..
P : Principle Amount
N : Time in Years
R : % Annual Rate of Interest
SI : Simple Interest
Algorithm
Step-1 Start
Step-3 SI = (P x N x R)/100.0
Step-4 Display SI F
Step-6 Stop
P : Principle Amount
N : Time in Years
R : % Annual Rate of Interest
CI : Compound Interest
Algorithm
Step-1 Start
Step-3 CI = P(1+R/100)N - P
Step-4 Display CI
Step-6 Stop
..
10 CIC-UHF
Algorithm & Flowchart Manual
Algorithm
Step-1 Start
Step-8 Stop
Algorithm & Flowchart to Swap Two Numbers without using temporary variable
11 CIC-UHF
Algorithm & Flowchart Manual
Algorithm
Step-1 Start
Step-4 A=A+B
Step-5 B=A-B
Step-6 A=A-B
Step-8 Stop
..
Algorithm
Step-1 Start
NUM1,NUM2
NUM2
ENDIF
Step-4 Stop
12 CIC-UHF
Algorithm & Flowchart Manual
Algorithm
Start
Step-1 Start
Stop
13 CIC-UHF
Algorithm & Flowchart Manual
..
Algorithm
Step-1 Start
14 CIC-UHF
Algorithm & Flowchart Manual
..
Algorithm
Step-1 Start
..
Algorithm & Flowchart to find the largest of three numbers (an another way)
Algorithm
Step-1 Start
Step-3 BIG = A
BIG = B
ENDIF
BIG = C
ENDIF
Step-7 Stop
15 CIC-UHF
Algorithm & Flowchart Manual
find Even number between 1 to 50
Step-2 I=1
Step-6 GO TO Step--3
Step-7 Stop
Algorithm
Step-1 Start
Step-3 I=1
Step-7 GO TO Step-4
Step-8 Stop
16 CIC-UHF
Algorithm & Flowchart Manual
..
Algorithm
Step-1 Start
..
Algorithm
Step-1 Start
Step-3 I = 1, SUM=0
Step-6 I=I+1
Step-7 Go to step-4
Step-9 Stop
17 CIC-UHF
Algorithm & Flowchart Manual
Algorithm & Flowchart to find sum of series 1+3+5+…..+N, Where N is positive
odd Integer
Algorithm
Algorithm
Step-1 Start
Step-3 I = 1, SUM=0
Step-6 I=I+2
Step-7 Go to step-4
Step-9 Stop
Step-7 I=I+1
Step-8 Go to step-4
Step-10 Stop
18 CIC-UHF
Algorithm & Flowchart Manual
..
Algorithm
Step-1 Start
Algorithm & Flowchart to print multiplication Table of a number
Algorithm
Step-1 Start
Step-3 I=1
Step-7 I=I+1
Step-8 Go to step-4
Step-9 Stop
..
19 CIC-UHF
Algorithm & Flowchart Manual
Algorithm
Step-1 Start
Step-4 WRITE A, B
Step-6 NEXT= A + B
Step-8 A=B
Step-9 B=NEXT
Step-10 COUNT=COUNT + 1
Step-11 Go to step-4
Step-12 Stop
20 CIC-UHF
Algorithm & Flowchart Manual
..
Algorithm
Step-1 Start
find sum and average of given series of numbers
Step-2 COUNT=0
Step-3 SUM=0
Step-6 COUNT=COUNT+1
GOTO Step-4
ENDIF
Step-10 Stop
21 CIC-UHF
Algorithm & Flowchart Manual
..
Algorithm
Step-1 Start
find Roots of Quadratic Equations
AX2+BX+C=0
Step-3 DISC= B2 – 4 A * C
22 CIC-UHF
Algorithm & Flowchart Manual
..
Algorithm
Step-1 Start
Stop
ENDIF
23 CIC-UHF
Algorithm & Flowchart Manual
..
Step-3 R=SQRT(NUM)
Step-4 I=2
Step-8 Go to Step-5
24 CIC-UHF
Algorithm & Flowchart Manual
..
Algorithm
Step-1 Start
find GCD and LCM of two numbers
Algorithm
Step-1 Start
Step-5 WHILE (r != 0)
DO
N=D D=r
r =N%D
DONE
Step-6 gcd=d
Step-7 lcm = (a*b)/gcd
Step-9 Stop
25 CIC-UHF
Algorithm & Flowchart Manual
..
26 CIC-UHF
Algorithm & Flowchart Manual
Algorithm
Step-1 Start
Step-6 Stop
27 CIC-UHF
Algorithm & Flowchart Manual
Algorithm
Step-1 Start
Step-3 D=1
Step-4 WHILE (D< N)
DO
IF ( N % D ==0) THEN
PRINT D
ENDIF
D=D+1
DONE
Step-5 Stop
28 CIC-UHF