Loops (for, while, do-while), Exercises / Bonus Material
Loops (for
, while
, do-while
), Exercises / Bonus Material
In this chapter, we will look into the basics of control-flow using loops (for, while, do while
), and also at some special increment / decrement operators. We will also work on several exercises including some bonus material.
- The Increment Operator "++" (plus-plus)
- Exercise - The Increment Operator ++ (plus-plus)
- The increment operator "+=" (plus equals-to)
- Exercise - The increment operator "+=" (plus equals-to)
- The Decrement Operator "--" (two minus signs)
- Exercise - The Decrement Operator "--" (two minus signs)
- The decrement operator "-=" (minus equals-to)
- Exercise - The decrement operator "-=" (minus equals-to)
- Introduction to Loops
- Exercise - Well-behaved computer
- Visualize Loops - Running Track Scenario
- Exercise - Running Track Scenario using "for loop"
- Exercise - Running Track Scenario using "while loop"
- Exercise - Print 1 to 10 using a "while loop"
- Exercise - Print 1 to 10 using a "do while loop"
- Loops - The different parts of a for loop
- Exercise - Print 1 to 10 using "for loop"
- Loops in descending order
- Loops with step size greater than 1
- Exercise - Print 10 down to 1 using a "for loop"
- Exercise - Print even numbers in 1 to 10 range using "for loop"
- Exercise - Print odd numbers in 1 to 10 range using "for loop"
- Exercise - Print how many times the loop runs (going up) part 1
- Exercise - Print how many times the loop runs (going up) part 2
- Exercise - Print how many times the loop runs (going down) part 1
- Exercise - Print how many times the loop runs (going down) part 2
- Exercise - The Star Equals Multiplication Operator
- Exercise - The ForwardSlash Equals Division Operator
- Exercise - "while loop" vs "do-while loop" - Free ice cream example
- Exercise - What's loop counter value at the end of the loop?
- Exercise - Infinite "for" loop - gate always open
- Exercise - Infinite "while" loop - gate always open
- Exercise - Infinite "do while" loop - gate always open
- Exercise - Fix Bug in "while loop" printing 1 to 10
- Exercise - Fix Bug in "while loop" printing 1 to 10 (Part 2)
- Exercise - Fix Bug in "while loop" causing infinite loop