Repeat Yourself
Use loops to repeat actions automatically.
We'll cover the following...
We'll cover the following...
Now you know how to perform some basic tasks in C++, but some tasks are repetitive, and loops do them best. In this lesson, you’ll learn how to repeat actions automatically using for and while loops.
Goal
You’ll aim to:
Use
forloops to count and repeat.Use
whileloops for flexible repetition.Understand loop flow.
Count with a for loop
Here’s the basic structure and breakdown of for loop in C++: