0% found this document useful (0 votes)
30 views26 pages

Chapter7-Iteration Statements - Counting, Totalling

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views26 pages

Chapter7-Iteration Statements - Counting, Totalling

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Algorithm & Problem

Solving
Lesson 4 – Iteration Statements
Learning Objective
To design pseudocodes for looping statement
Analyze the various standard methods of solution used in a
program(Counting and Totalling, maximum, minimum and
average)
Locate the syntax and logical errors in the given program

Learning Outcomes
Write pseudocode for Count- controlled ,Pre-conditioned
loop, Post- conditioned loop
Create python programs based on the given pseudocode

2
STARTER

Predict the output of the flowchart, fill in the textbox

3
Iteration
The looping can be defined as repeating the same process multiple times
until a specific condition satisfies.
There are three types of iteration statement

FOR … TO … NEXT ( count controlled loop)


WHILE … ENDWHILE (pre-conditioned loop)
REPEAT … UNTIL (post conditioned loop)

4
FOR... TO… NEXT REPEAT... UNTIL WHILE… DO...

FOR Counter ← 1 Counter ← 1 Counter ← 1


TO 10 REPEAT WHILE Counter <
PRINT PRINT “Welcome” =10 DO
“Welcome” PRINT “Welcome”
Counter ←
Counter ← Counter
NEXT Counter + 1 +1
UNTIL Counter ENDWHILE
>10 Welcome
Welcome
Output Welcome
Welcome
Welcome
Welcome
Welcome
Welcome
Welcome
5
Welcome
TASK-1
Write pseudocode to print your name 10 times. Using
all the three looping statements
Mid Plenary--Effective
Questioning
1)Justify why while loop and repeat until is known as pre and
pre –conditioned loop?
2)Make a prediction (think, write, pair, share)
What will be the output when this code is executed?

7
STANDARD METHODS OF SOLUTIONS

•» Totalling
•» Counting
•» Finding maximum, minimum, and average (mean) values
•» Searching using a linear search
•» Sorting using a bubble sort.
Counting
Totalling
Keeping a count of the number of
Totalling means keeping a total that times an action is performed is
values are added to. For example, To find another standard method. For
the total mark of students in a class example, counting the total
number of students passed in a
Total ← 0 class(consider pass mark is 50)
FOR Counter ← 1 TO 30 passcount ← 0
OUTPUT ”Enter the student mark” FOR Counter ← 1 TO 30
INPUT studentmark INPUT studentmark
Total ← Total + studentmark IF studentmark > 50
NEXT Counter THEN
OUTPUT Total passcount ← passcount + 1
NEXT Counter
ACTIVITY-1
Rewrite the given program in FOR … TO … NEXT and
WHILE … ENDWHILE
Total ← 0
FOR Counter ← 1 TO 30
OUTPUT ”Enter the student mark”
INPUT studentmark
Total ← Total + studentmark
NEXT Counter
OUTPUT Total
WHILE REPEAT UNTIL
Total ← 0 Total ← 0
Counter← 1 Counter← 1
While Counter<=30 REPEAT
OUTPUT ”Enter the student mark” OUTPUT ”Enter the student mark”
INPUT studentmark INPUT studentmark
Total ← Total + studentmark Total ← Total + studentmark
Counter=Counter+1 Counter=Counter+1
End While UNTIL Counter >30
OUTPUT Total OUTPUT Total
AVERAGE Calculating the average (mean) of all the values in
a list is an extension of the totalling method.

Total ← 0
Avg← 0
FOR Counter ← 1 TO 30
OUTPUT ”Enter the student mark”
INPUT studentmark
Total ← Total + studentmark
NEXT Counter
Avg=Total/Counter
PRINT Avg
Task-1
Write pseudocode to input any 10 numbers .Find its Total and
Average

Task-2
SOLUTION:
Task-1 Task-2
count1
Total0
WHILE count<=10
Print ”Enter the number”
input Number
Total=Total + Number
count=count+1
End While
Avg=Total/count
Print “The Total is", Total
Print “The Average is", Avg
KAHOOT

https://create.kahoot.it/my-library/kahoots/227c851d-f671-4372-a62c-6050b44176d0

15
TaskWrite
TASK-1 1 an algorithm in pseudocode for any one the
given problems.
Group-1
1)To input fifty numbers and find its average

Group-2
To input fifty numbers and find the total of positive numbers

Group-3
To input fifty numbers and find the largest of the
given numbers

teachcomputerscience.co
m
GROUP-A

GROUP-C

GROUP-B

17
Past paper
practice 1)

18
SOLUTION

19
Past paper
practice 2)

20
SOLUTION

21
Past paper practice 3)

22
23
24
plenary
plenary

You might also like