Pseudocode(Loop1)
Pseudocode(Loop1)
AHIS CS 1
Contents
Previous class topics(Conditional Statements)
Loop statements
FOR..TO..NEXT
AHIS CS 2
Activity(Showing 7 days of week)
INPUT Day
CASE Day OF
1 : PRINT “Sunday”
2 : PRINT “Monday”
3 : PRINT “Tuesday”
4 : PRINT “Wednesday”
5 : PRINT “Thursday”
6 : PRINT “Friday”
7 : PRINT “Saturday”
OTHERWISE
PRINT “ Error”
END CASE
AHIS CS 3
Loop Statement
For Loop
Why Loop?
No condition checking Checks conditions at the start Checks condition at the end
of loop of loop
AHIS CS 7
FOR…TO..NEXT Loop
A FOR loop is used when the loop is to be repeated
a fixed number of times.
The loop ends when the counter matches the
number of times the loop is to be repeated.
EXAMPLE PSEUDO CODE (FOR…
TO..NEXT)
Pseudo code for printing 10 stars(*)
FOR Counter 1 TO 10
PRINT “*”
NEXT
EXAMPLE PSEUDO CODE
(REPEAT..UNTIL)
Pseudo code for printing 10 stars(*)
Counter 0
REPEAT
PRINT “*”
Counter Counter+1
UNTIL Counter =10
EXAMPLE PSEUDO CODE
(WHILE..DO..END..WHILE)
Pseudo code for printing 10 stars(*)
Counter 0
WHILE Counter < 10 DO
PRINT “*”
Counter Counter+1
ENDWHILE
Write a pseudocode to input 100 numbers
and print out the sum.(FOR-TO-NEXT)
Sum 0
FOR Count 1 TO 100
INPUT Number
Sum Sum + Number
NEXT Count
PRINT Sum
Jobayer 12