0% found this document useful (0 votes)
10 views

Pseudocode(Loop1)

Chapter 10 discusses pseudocode and flowcharts, focusing on loop statements including FOR..TO..NEXT, REPEAT..UNTIL, and WHILE..DO..ENDWHILE. It explains the purpose of loops for iteration and provides examples of pseudocode for printing stars and summing numbers. The chapter highlights the differences between the various loop structures and their conditions for repetition.

Uploaded by

afsanajahan2342
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Pseudocode(Loop1)

Chapter 10 discusses pseudocode and flowcharts, focusing on loop statements including FOR..TO..NEXT, REPEAT..UNTIL, and WHILE..DO..ENDWHILE. It explains the purpose of loops for iteration and provides examples of pseudocode for printing stars and summing numbers. The chapter highlights the differences between the various loop structures and their conditions for repetition.

Uploaded by

afsanajahan2342
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Chapter 10

Pseudocode and Flowcharts

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?

 Sometimes a section of code is run repeatedly, is called


iteration. Loop structures are used to perform the
iteration.
Example :
for entering a series of numbers, the input code
will need to be repeated until all numbers have been
entered.
Three types of loop structure:
FOR…….TO….NEXT... (Count controlled)
REPEAT……..UNTIL ... (Post Conditional)
WHILE….DO…..ENDWHILE ... (Pre Conditional)
Differences
FOR..TO..NEXT WHILE..DO REPEAT..UNTIL
Repeat statements are fixed Repeat statements when Repeat statements when
number of times condition is true condition is false

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

You might also like