Challenge: Sequences and Loops
Explore how to print number sequences using for loops in C++, including multiples of ten, odd numbers, and complex arithmetic sequences. Learn to implement loops effectively to solve coding challenges and prepare for efficient algorithm design.
We'll cover the following...
Printing number sequences using loops
In this lesson, let’s practice what we’ve learned so far with a few coding challenges.
Print the following number sequences using the for loop.
Multiples of 10
Your code should print the following sequence:
10 20 30 40 50 60
Good luck!
Congratulations! Give yourself a round of applause.
In case you’re stuck, go over the solution review in the next lesson.
Odd sequence
Your code should print the following sequence:
1 3 5 7 9 11
Good luck!
Congratulations! Give yourself a round of applause.
In case you’re stuck, go over the solution review in the next lesson.
Arithmetic sequence
Your code should print the following sequence:
1 1 3 6 5 11 7 16
Good luck!
If you look closely, there are actually two sequences starting from 1, but the change factor is different.
Congratulations! Give yourself a round of applause.
In case you’re stuck, go over the solution review in the next lesson.