Questions tagged [looping]
Use this tag for questions related to teaching and learning the various forms of repetition in computer programming. Tradeoffs between the various semantic forms can be discussed. This tag is not appropriate for specific recursion questions, though questions relating to comparison of recursive vs repetitive solutions might be.
9
questions
40
votes
13answers
6k views
Teaching the humble for loop
So, in C-style languages, the for loop has a funny little syntax:
for (int i = 0; i < 100; i++) {
// do something
}
If ...
10
votes
7answers
2k views
Order to teach looping constructs in a non ideal language
In an ideal teaching language
If the language directly supports them then the order to teach looping constructs seems simple.
Infinite loop: forever.
Simple finite ...
7
votes
6answers
443 views
Single-dimensional array and simple looping activities of significance
I give a lab on single-dimensional loops and arrays. By "single dimensional loops", I mean that there is no nesting of loops. (I will later give a second lab on multi-dimensional loops and arrays, ...
7
votes
5answers
133 views
Practical application of loop, e.g. check prime number
I am teaching some high school students, also the first time programmers, some basic programming concepts and applications. When introducing loop I find that using it to check prime number (or find ...
7
votes
7answers
1k views
Example for For vs While Loop (in Java)
I'm looking for a set of concrete examples that illustrates good use cases of using a for vs a while loop for beginners. I feel ...
6
votes
4answers
785 views
How to teach which loop should be used
In most languages, there are many different types of loops. The most common ones seem to be for loop, while loops, and do while loops.
What is the best way to illustrate the differences between the ...
5
votes
12answers
1k views
Teaching the tradeoffs of the foreach loop
Edit: It's been quite a while since I posted this question, and in the intervening time, I have come to love the foreach loop. However, in order to avoid invalidating answers, I leave the text ...
4
votes
7answers
267 views
Pedagogical reasoning behind a minor difference in two loops
I keep seeing examples like the first program bellow, in teaching materials.
Is there a pedagogical reason to teach this first program, compared to the second?
...
3
votes
2answers
298 views
Using physical activity to explain the nested for loop
I have been rewriting my unit on nested for loops for AP Computer Science (thus, we are using Java). I would like to use some sort of physical activity to drive home the differences between roughly ...