Pseudocode and Flowcharts
Pseudocode and Flowcharts
FLOWCHARTS
CONDITIONAL STATEMENTS, PSEUDOCODE AND LOOPING
STRUCTURES.
REVISION
DEFINE….
Write down pseudocode that will take a number as input (from 1 to 7) and print
the day name for corresponding number example 1 for Monday 2 for Tuesday
and so on.
SOLUTION
LOOP STRUCTURES
Example 4: Write pseudocode that will take 10 numbers as input and print their
average by using FOR…TO…NEXT loop.
SOLUTION
WHILE … DO … ENDWHILE
This repetition statement is used when we don’t know how many times an
instruction or set of instructions is to be repeated.
Few things to remember about WHILE…DO…ENDWHILE loop are:
The loop is repeated until a condition is true and halted when the condition is false.
Condition is tested at the beginning of the loop.
The statements/instruction between DO and ENDWHILE keywords are repeated.
LOOP STRUCTURES
Write pseudocode that will take numbers input and add them while the input
number is greater than or equal to 0. Print the final result using WHILE…
DO…ENDWHILE.
SOLUTION
REPEAT … UNTIL
It is a repetition statement that is used when we don’t know how many times an
instruction or set of instructions is to be repeated.
It is different from WHILE… DO … ENDWHILE because this loop will be
repeated until a condition is false and it will stop executing once the condition
is true.
The condition is tested at the end of the loop and even if a condition is true the
loop will execute at least once.
LOOP STRUCTURE
Write the pseudocode that will take numbers as input, add and gives the total as
output. The loop will continue until “0” is given as input. Use REPEAT…
UNTIL.
SOLUTION
Thank You!