Page 106 - Plus V4 with Adobe class 6
P. 106
SOLVING PROBLEMS USING ALGORITHMS AND FLOWCHARTS
Some examples are given below to solve the problems using algorithms and flowcharts:
Example 1: Write an algorithm and draw a flowchart to check weather a given number is even
or odd.
Algorithm: Flowchart:
Step 1: Start.
Start
Step 2: Read Number.
Step 3: Check If Number % 2 == 0 Then
Read a Number
print "Number is even."
Else
Is
print "Number is odd." Yes
Number%2==0? Print Number is even
Step 4: End.
No
Print Number is odd
Stop
Example 2: Write an algorithm and draw a flowchart to find the smallest in two numbers A and B.
Algorithm: Flowchart:
Step 1: Start. Start
Step 2: Read two numbers and store them
in A and B.
Read A and B
Step 3: Compare number A and B. If A is
less than B, then
print "A is smallest" if Yes
A < B Print A is smallest
Else
print "B is smallest" No
Step 4: End.
Print B is smallest
Stop
104 Plus (Ver. 4.0)-VI

