C++ Tutorial - WHILE Loops & FOR Loops Tutorial
Zenva
ACCESS the FULL COURSE here: https://academy.zenva.com/product/c-foundations/?zva_src=youtube-c++-programming-bundle
TRANSCRIPT
Now that we can perform tests and execute code once, the next step is to be able to perform tests and execute code multiple times as long as some condition continues to be true. For this, we use loops. Loops provide a way to execute code multiple times without having to type the same code again and again.
The simplest form is the while loop and it acts very much like an if statement run multiple times. It performs a test and executes code if the test returns true but instead of executing the code once, it continuously executes the code until the test eventually returns false. This can be dangerous because if the test never returns false, the loop will run infinitely and the program will crash so we need to make sure that we build the loop in such a way that it will eventually exit.
The next type of loop is the for loop. This acts similar to a while loop but it runs a set number of times. We build right into the loop when to start and when to stop so we know how many times it will run. This makes it great for pairing with collection types as we can just set the start point to be the beginning of the collection and the end point to be the end and visit each element in the collection.
Free resources: https://linktr.ee/zenva
Free Tutorials:
- Unity: https://gamedevacademy.org
- Phaser: https://phasertutorials.com
- Godot: https://godottutorials.pro
- Machine Learning: https://pythonmachinelearning.pro
- Web Dev: https://html5hive.org
- Android: https://androidkennel.org
- Swift: https://swiftludus.org
- VR: https://vrgamedevelopment.pro ... https://www.youtube.com/watch?v=cjnQ1bihQvA
13767587 Bytes