Problem Solving: Algorithms and Flowcharts: CSC 110-Introduction To Computer Systems
Problem Solving: Algorithms and Flowcharts: CSC 110-Introduction To Computer Systems
ALGORITHMS AND
FLOWCHARTS
CSC 110- Introduction To Computer
Systems
DECISION STRUCTURES
Y N
is
A>B
Print Print
A B
IF–THEN–ELSE STRUCTURE
Print Print
A B
Relational Operators
Relational Operators
Operator Description
> Greater than
< Less than
= Equal to
Greater than or equal to
Less than or equal to
Not equal to
Example 5
START
Input
VALUE1,VALUE2
Y is
N
VALUE1>VALUE2
Print
“The largest value is”,
MAX
STOP
NESTED IFS
Write an algorithm that reads three numbers and prints the value of the largest
number.
Example 6
Step 1: Input N1, N2, N3
Step 2: if (N1>N2) then
if (N1>N3) then
MAX N1[N1>N2, N1>N3]
else
MAX N3[N3>N1>N2]
endif
else
if (N2>N3) then
MAX N2[N2>N1, N2>N3]
else
MAX N3 [N3>N2>N1]
endif
endif
Step 3: Print “The largest number is”, MAX
Example 6 (Class Activity)
Bonus Schedule
OVERTIME – (2/3)*ABSENT Bonus Paid
Example 4: The program is to input a number and find the factorial if number
is non-negative.
Examples Conti… (Flow Chart?)
Design a program that reads a set of 15 integers and then finds and prints the
sum of the even and odd integers.