Cursusinhoud
C++ Introductie
C++ Introductie
2. Inleiding tot Operatoren
3. Variabelen en Gegevenstypen
4. Introductie tot Programmastroom
5. Introductie tot Functies
Voor Lus
De for-lus is complexer dan de andere lussen en bestaat uit drie delen. Structuur van de for-lus:
python
Teller;
Eindvoorwaarde;
Lusuitdrukking.
main
#include <iostream> int main() { for (int counter = 0; counter <= 5; counter++) { std::cout << counter << std::endl; } }
int counter = 0
: iteratie teller;counter++
: Voor elke iteratie wordt 1 toegevoegd aan decounter
variabele om de doorgang van de lus te markeren;counter <= 5
: lus beëindigingsvoorwaarde. De lus gaat door als decounter
variabele kleiner dan of gelijk aan 5 is.
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 4. Hoofdstuk 5