Exercises: Repetitions (Loops)

Now that we are familiar with loops, it is time to practice our newly acquired skills, and as you know, this is achieved by a lot of code writing. Let's solve some practical problems.

Video: Chapter Summary

Watch this video to review what we learned in this chapter: https://youtu.be/4G_oSUcx9ko.

What We Learned in This Chapter?

We can repeat a code block using a for loop:

We can read a sequence of n numbers from the console this way:

Blank Solution in Visual Studio

Before starting with the exercises, we will create a Visual Studio solution with the idea to hold the code for each exercises problem in a separate C# project inside the solution.

Create a (Blank Solution) in Visual Studio:

Set it up to start the current project by default (not the first one in the solution). Do that by right clicking on Solution 'Loops' -> [Set StartUp Projects…] -> [Current selection].

The Problems

Now it's time to start working on the problems: