for loop while loop do-while loop for (begin point; end point ; incrementation ) { //statements to...

21
Loops Lesson 4

Transcript of for loop while loop do-while loop for (begin point; end point ; incrementation ) { //statements to...

Slide 1

LoopsLesson 4

In this presentation, we are going to learn about how to repeat a section of code using the different types of loops1Objectivesfor loopwhile loop do-while loop

Our goal is to review the different constructs for repeating a body of code. In C++, there are 3 different type of looping statements: the for loop, the while loop and the do-while loop.2for loop Syntaxfor (begin point; end point ; incrementation ) { //statements to be repeated }

This is the general syntax of the for loop. You write the keyword for, inside a set of ( )s, you specify the begin point, the end point, and the incrementaion separated by ;s. Inside a set of { }s you put the code that you want repeated.3for loop Examplefor (c = 0; c < 10 ; c++ ) { cout