This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:c4eng:fall2024:projects:stl2 [2024/10/09 02:45] – [bitwise AND] skephart | notes:c4eng:fall2024:projects:stl2 [2024/10/09 15:14] (current) – [while loop] dprado | ||
---|---|---|---|
Line 11: | Line 11: | ||
The looping variable is " | The looping variable is " | ||
====for loop==== | ====for loop==== | ||
+ | A type of control flow statement that allows you to execute a desired task a specified number of times. The general form we see is as follows: | ||
+ | if(initialization; | ||
+ | {task we wish to execute} | ||
+ | | ||
+ | Initialization: | ||
+ | Condition: This part is evaluated at the start of each successive loop. If the condition is " | ||
+ | Update: Executed after each iteration, this term is used to update the loop control variable> | ||
====while loop==== | ====while loop==== | ||
A type of control flow statement that will continue to run whatever code is written in the body as long as the predetermined condition is met. For example, in this class, we see the while loops with the condition (1) which simply means " | A type of control flow statement that will continue to run whatever code is written in the body as long as the predetermined condition is met. For example, in this class, we see the while loops with the condition (1) which simply means " | ||
while (1) | while (1) | ||
- | { | + | |
- | task we wish to repeat here | + | {task we wish to repeat here} |
- | } | + | |
====do-while loop==== | ====do-while loop==== | ||