Introduction to Loops

In the last lesson, we learned how to store multiple data in a single variable using arrays and how to manipulate arrays. In this lesson, we will find out how to repeat a part of the code based on a condition.

Repetition, or iteration, is an extremely important concept in programming, which we utilize in the form of loops.

We will show some examples of where loops are used.

Imagine you have an array of 500 students, each with an age stored, and each year we need to update their age. You can probably imagine how exhausting it would be to reset the age for each student individually. Therefore, we can use a loop that goes through each student and updates their age.

Or in a game, when you have 60 FPS, it means the game code repeats 60 times per second. Every game is basically one big loop that keeps repeating. In this case, it would be practically impossible to create a game without loops.

Now that we know why loops are important, we can move on to the next exercise and start using loops!

Instructions

When you're ready, proceed to the next exercise!

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

1/8

Introduction to Loops | Start Coder