UNIT 3b - Data Types, Variables and Flowcharts
UNIT 3b - Data Types, Variables and Flowcharts
INTRODUCTION TO STRUCTURED
PROGRAM DESIGN
Start
If studentgrade >= 60
Print “Passed”
Stop
IF…ELSE SELECTION STATEMENTS
Yes No
ITERATIVE PROCESSING
● These are created with repetition statements
• – while
• – do…while
• – For
ITERATIVE PROCESSING: While loop
• A WHILE loop is a loop that repeats while some
condition is satisfied.
1. Start
2. count = 0
3. While count < 5
Display "I love computers!"
4. Increase count by 1
5. Endwhile
6. Stop
ITERATIVE PROCESSING: WHILE LOOP
● Actions are repeated based on the answer
to a question
No
Yes
ITERATIVE PROCESSING:
The do-While and the do-Until Loops
While Loop
Do-while or Do-until loop
STACKING STRUCTURES
● ALL logic problems can be solved using only
these three structures
● They can be combined in an infinite number
of ways
● Attaching structures end-to-end is called
stacking
stepA
Sequence
do stepA
stepB do stepB
if conditionC is true then
do stepD
No condition Yes
C?
else
Selection do stepE
stepE stepD endif
while conditionF is true
do stepG
endwhile
Yes
conditionF
? stepG
Loop
No
EXERCISES
● Draw a flowchart to read any 10 integers that a user will input. Output
the sum of the even numbers in the list entered.
● Draw a flowchart to calculate the sum and average of n numbers.
● Draw a flowchart that finds and displays the larger of two numbers
provided they differ.
● The voltage (V) between the poles of a conductor is equal to the
product of the current (I) passing through the conductor and the
resistance (R) present on the conductor. It’s demonstrated by the V = I
* R formula. Draw a flowchart to calculate the voltage between the
poles of the conductor by using the formula according to the current
and resistance values the user enters.
!!!STUDENTS TO READ!!!
● Research on the CASE STRUCTURE .
● Use the CASE STRUCTURE to assign grades scored by a class in
Programming based on the following metrics:
SCORE GRADE
0-49 F
50-59 D
60-69 C
70-79 B
80-100 A
NEXT TOPIC
● Modules
END