Grade 10 - Unit 5 - Program 5
Grade 10 - Unit 5 - Program 5
Book)
Iteration
Ms. Naureen Q
Coronavirus
health and safety tips
Cover your sneezes Avoid close Use your own Avoid shaking
and coughs contact supplies hands
3
WHILE
4
Objective
10
20
30
40
50
60
70
80
90
100
START In Pseudocode the Do is placed after the condition:
WHILE ‘condition’ DO
code to be iterated
Counter 0 LOOP
Multiple 0
But when programming in VB it is placed at the
INPUT beginning: DO WHILE
Number
INT: Counter 0
No INT: Multiple 0
Counter
END
<=10?
INPUT Number
Yes
Multiple WHILE Counter <= 10 DO
Number * Counter
Multiple Counter * Number
OUTPUT OUTPUT Multiple
Multiple Counter Counter + 1
Counter
Counter + 1 Loop
Programming Codes
Dim multiply As Integer
Dim counter As Integer
Console.WriteLine("input num")
multiply = Console.ReadLine
Do While counter <= 10
Console.WriteLine(multiply * counter)
counter = counter + 1
Loop
Console.ReadKey()
8
Objective
✖ While Loop can check multiple condition at a time because of this it can
provide an efficient solution.
In Common language example would be ‘If I had pilot license and a jet I could travel
anywhere anytime’
11
Enter a number: 5
Prime Number
Enter a number: 6
Not a Prime Number
START
Boolean variable can have either Counter 2
a TRUE and FALSE value. It is Num 0 END
used to indicate a condition of a Modulus 0
Prime True
statement.
INPUT OUTPUT
Number “Prime
Number”
Yes
Counter < Num
No
–1 Prime =
AND True
Prime = True
No
Yes OITPUT
Modulus Num
Mod Counter “Not a Prime
Number”
Counter Prime Yes Modulus
Counter + 1 False =0
END
No
13
IF Prime = True
INT: Num 0
OUTPUT “Number is Prime”
INT: Modulus 0
Else
INT: Counter 2
OUTPUT “Not Prime Number”
BOOLEAN: Prime True
END IF
INPUT Num
Console.WriteLine("Enter a Number")
Num = Console.ReadLine
Objective
INPUT Num