Page 73 - CloudGPT_C8_Flipbook
P. 73
5 LOOPS USING BLOCK CODING
Learning Outcomes
Introduction Loop
Incrementing a Loop Different Types of Loops
Nested Loop Entry Criteria
Exit Criteria Jump Statement
INTRODUCTION
You perform a variety of tasks daily, such as eating meals, taking a bath, watching TV, doing
homework, going to school, etc. You perform these tasks daily and repeat them at specific
intervals of time. There is a similar concept in programming, it is known as looping. In this
chapter you are going to learn more on looping.
LOOP
A loop is a construct which executes a block of code multiple times until a specific condition
is met.
Benefits:
Reduces lines of code
Code becomes easier to understand
Consider an example:
Suppose you want to print alphabets from a to d on the screen. You can do this by printing
the values a, b, c and d by writing four lines of code like:
Program Start Output:
Print a a
Print b b
Print c c
Print d d
Program End
Doing this was easy. What if, you need to print numbers in incremental order from 1 to 1000.
Loops Using Block Coding 71

