Page 23 - Touchcode_C8_Flipbook
P. 23
2 GET CREATIVE WITH LOOPS
Learning Outcomes
Introduction What are Loops?
Different Types of Loops Nested Loop
Exit Criteria
INTRODUCTION
You perform a variety of tasks daily, such as eating meals, taking 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 about looping.
WHAT ARE LOOPS?
A loop is an algorithm which executes a block of code multiple times until a specific condition
is met. Loops are programming elements which repeat a portion of code for a number of
times till the desired process is complete. Repetitive tasks are common in programming
and loops are important to save time and minimize errors.
Coding uiz 01 Critical Thinking
State whether the following statements are true (T) or false (F).
a. A loop executes a block of code multiple times.
b. Loops do not save time and minimize errors.
DIFFERENT TYPES OF LOOPS
Loops make the code more manageable and organized. There are different types of loops.
Although they perform the same task, but their working is bit different.
Different types of loops are:
While Loop
For Loop
Get Creative with Loops 21

