San Diego State University logo
ME 203

Module 2.1 - Loop Basics

Although do loops and while loops can be used in situations where incrementation of a variable is needed, they are somewhat cumbersome in these scenarios, since they force the programmer to intialize and perform the incrementation in a computationally "safe" area within the program.

A looping mechanism that had the initialization, incrementation and condition-testing facilities built into the looping structure itself would be very helpful in allowing the programmer to spend less time considering where and when to initiate, increment and test the looping variable, and more time thinking about the critical calculations within the loop itself.

The 3rd looping method provided within the C programming language, the for loop, does exactly this.

And it turns out that the built-in nature of the initialization and incrementation of the looping variable will become increasingly important when we begin to consider the notion of nested loops (where we incorporate a loop within a loop), in the next module.

Continue to the Next Looping Module ->

Website by Joshua Bleier