Skip to main content

6 docs tagged with "loops"

View all tags

Combining Loops and Conditionals

In this final article of the series, we'll see how to combine loops and conditionals to create more sophisticated programs. This is where the real power of programming begins to show.

Loops: for loops (Part 1)

Welcome to the world of loops! Loops are used to execute a block of code repeatedly. The for loop is ideal when you know in advance how many times you want to iterate.

Loops: for loops (Part 2)

In this article, we'll explore nested for loops, which are loops inside other loops. This is a powerful technique for working with two-dimensional data structures or creating patterns.

Loops: foreach loops

The foreach loop provides a simple, clean way to iterate over the elements of a collection, such as an array or a list.

Loops: while and do-while loops

Unlike for loops, while and do-while loops are used when you don't know how many times you need to iterate. The loop continues as long as a condition is true.