Algorithm&Flowchart I
Algorithm&Flowchart I
1
Algorithm
▪ Before writing program, we need to write the steps to solve the problem
in simple English language
2
Flowchart
3
Flowchart Symbols:
Connector
4
5
Write an algorithm to read two numbers and find their sum.
6
Find the area of a Circle of radius r.
7
Write an algorithm (FlowChart) to find the area of a rectangle.
8
Write an algorithm in flowchart that finds the average of three numbers
9
IF
Create a flowchart for a simple login system. The flowchart should include steps for entering a
username and password, checking their validity, and displaying a success or failure message.
No
Yes
Stop
10
IF
No
No
Yes
11
Create a flowchart to convert the weight in kg to lbs. ( 1kg =2.2 lbs)
Design a flowchart to determine the grade of a student based on the percentage obtained.
12
To decide the mark is pass or Fail
START
INPUT mark
NO Mark Yes
>40
OUTPUT OUTPUT
“Fail” “Pass”
13
STOP
To decide the day is weekday or weekend
START
INPUT Day
Day==
NO Saturday Yes
OR
Sunday
OUTPUT OUTPUT
“Weekday” “Weekend”
14
To decide a bigger number of two numbers
START
INPUT x,y
NO Yes
x>y
OUTPUT “y OUTPUT “x
is bigger” is bigger”
STOP 15
To decide the mark is A*, A, B, C or D. (mark > 90 =A*,
mark>80 =A, mark>60 =B, mark >40 =C, otherwise D.
INPUT mark
NO NO NO NO
Mark> Mark> Mark> Mark>
=90 80 60 40
OUTPUT
“A*” OUTPUT “A” OUTPUT “B” OUTPUT “C” OUTPUT “D”
16
STOP
For Loop and While Loop
A for loop repeats statements as long as the last A while loop is to execute statements as
item in the range has not been reached yet. long as a condition holds.
17
Conditional
Draw a flowchart to reads two values, determines the largest value and prints the
largest value with an identifying message.
18
Basic Data Types
Integer : Whole Number
String : Text
19
Draw the flow chart to find the difference of two numbers and show the result.
Draw flowchart to calculate cashback. Ask user to enter purchase amount. If purchase amount is >100, then
Give cashback to 100 else make no change to cashback . Display the cashback.
Create a flowchart that displays your age five years from now.
The algorithm should have a variable that is initialized to your current age.
20
Flowchart to print numbers from 1 to 10 using loop
START
N=1
N<11
N=N+1
OUTPUT N
STOP
21
Flowchart to print odd number between 1 to 10
START
N=1
N<10
N=N+2
OUTPUT N
STOP
22
Flowchart to print even numbers from 1 to 10
START
N=2
No
N<=10 N=N+2
YES
OUTPUT N
STOP 23
Flowchart to print even numbers from 1 to 50
START
X=1
Yes
X>50
No
Yes
X%2=0 OUTPUT X
No
X=X+1
STOP 24
Flowchart to find and output Profit or Loss Amount
START
INPUT Cost
INPUT
SellingPrice
YES
SellingPrice > Cost Profit=SellingPrice-Cost
No OUTPUT
Profit
Loss=Cost-SellingPrice
OUTPUT
Loss
STOP
Flowchart to print sum up of all numbers from 1 to 5
26
Flowchart to print sum up of all numbers from 1 to 5
27
Flowchart for the problem of printing even numbers between 9 and 100:
28
29
1.Write an algorithm to check whether given number is positive , negative or
zero.
2.Create a flowchart that ask the user's age. Compute and display his/her
age five years from now.
3.Draw a flowchart that will ask the user to enter a character indicating the
user's gender. If the user enters 'M' display "You're a male". If not assume
that the user is a female. Thus, display "You're a female".