User Tools

Site Tools


notes:c4eng:fall2024:projects:stl2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:c4eng:fall2024:projects:stl2 [2024/10/09 02:45] – [bitwise AND] skephartnotes:c4eng:fall2024:projects:stl2 [2024/10/09 15:14] (current) – [while loop] dprado
Line 11: Line 11:
 The looping variable is "index", the loop starts when index=0, will continue to loop as the index increases by a value of 1 for each loop, and will stop/end when index=10, with the value stored in "index". The looping variable is "index", the loop starts when index=0, will continue to loop as the index increases by a value of 1 for each loop, and will stop/end when index=10, with the value stored in "index".
 ====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; condition; update) 
 +  {task we wish to execute}
 +  
 +Initialization: Typically used to initialize a loop control variable (we used "index" in class).
 +Condition: This part is evaluated at the start of each successive loop. If the condition is "true," the loop is run and the code is executed. If the condition is "not true," then the loop is terminated. 
 +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 "true." This means that as long as the condition is true (1) the loop will continue to run until it is interrupted by the user. The format we see in this class is  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 "true." This means that as long as the condition is true (1) the loop will continue to run until it is interrupted by the user. The format we see in this class is 
  
 while (1) while (1)
-{ + 
-task we wish to repeat here +{task we wish to repeat here}
-}+
 ====do-while loop==== ====do-while loop====
  
notes/c4eng/fall2024/projects/stl2.1728441909.txt.gz · Last modified: 2024/10/09 02:45 by skephart