# 1.7 Scr0370: the repeat loop in scratch 2.0  (Page 2/7)

 Page 2 / 7

## General background information

In an earlier module (see Resources ) , I told you that any programming logic problem could be solved using anappropriate combination of only three programming structures, none of which are complicated. The three structures are known generally as:

• The sequence structure.
• The selection or decision structure.
• The loop, repetition, or iteration structure.

I explained the sequence and selection structures in earlier modules. I will concentrate on the loop structure in this and the next module.

## Definite versus indefinite loops

Loop structures in programming fall into two broad categories:

• Definite loops
• Indefinite loops

There are numerous sub-categories within these broad categories. I will illustrate the difference between a definite loop and an indefinite loop with two real-world examples.

## A definite loop example

Assume that you are confronted with a full box of cookies. Assume also that you have more self-control than most of us, and that you decide you can eatthree cookies, but no more than three, in order to keep your waistline under control. You might eat the three cookies using an algorithm something like thatshown in Image A .

## Explanation of the definite loop

Being the self-controlled individual that you are, you would set your cookie limit to 3 and you would set count to 1. You would then test count to see if it is within the range from 1 to 3 inclusive. If so, you would take acookie from the box and eat it. Then you would increase the value of count by 1 and go back to the top of the loop.

Back at the top of the loop, you would once again test the value of count to determine if it is still within the range from 1 to 3 inclusive. If so, youwould repeat the process, getting and eating another cookie, increasing the value of count by 1, and going back to the top of the loop.

When you find that the value of count has advanced to 4, you would recognize that this is outside the range of 1 to 3 inclusive. As a result, youwould terminate the loop and stop eating cookies. Well done!

## An indefinite loop example

Assume once again that you are confronted with the same full box of cookies. However, like many of us, you aren't blessed with a lot of self-control. In thatcase, you might eat cookies using the algorithm shown in Image B .

## Explanation of the indefinite loop

Unfortunately, for many of us, as soon as we see the full box of cookies, our stillHungry variable gets set to true.

We begin the process by performing a test to determine if stillHungry is true and the box of cookies is not empty. If that test returns true, we take a cookie from the box and eat it. Then we perform another test. If weare no longer hungry at that point, we set our stillHungry variable to false and go back to test at the top of the loop. Otherwise, we allow our stillHungry variable to remain true.

Back at the top of the loop, we test again to determine if stillHungry is true, and the box of cookies is not empty. If the test returns true, we gothrough the process again, eating another cookie, etc.

how can chip be made from sand
is this allso about nanoscale material
Almas
are nano particles real
yeah
Joseph
Hello, if I study Physics teacher in bachelor, can I study Nanotechnology in master?
no can't
Lohitha
where is the latest information on a no technology how can I find it
William
currently
William
where we get a research paper on Nano chemistry....?
nanopartical of organic/inorganic / physical chemistry , pdf / thesis / review
Ali
what are the products of Nano chemistry?
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
learn
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
learn
da
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Bhagvanji
hey
Giriraj
Preparation and Applications of Nanomaterial for Drug Delivery
revolt
da
Application of nanotechnology in medicine
has a lot of application modern world
Kamaluddeen
yes
narayan
what is variations in raman spectra for nanomaterials
ya I also want to know the raman spectra
Bhagvanji
I only see partial conversation and what's the question here!
what about nanotechnology for water purification
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
Nasa has use it in the 60's, copper as water purification in the moon travel.
Alexandre
nanocopper obvius
Alexandre
what is the stm
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
Hafiz
what is Nano technology ?
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
how did you get the value of 2000N.What calculations are needed to arrive at it
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!