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:38] – [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==== | ||
Line 24: | Line 30: | ||
====bitwise AND==== | ====bitwise AND==== | ||
- | A bitwise AND is one of the multiple different bitwise functions that can be used not only to strengthen code but also to shorten code and make the code more succinct and more efficient. A bitwise AND is represented by the "&" | + | A bitwise AND is one of the multiple different bitwise functions that can be used not only to strengthen code but also to shorten code and make the code more succinct and more efficient. A bitwise AND is represented by the "&" |
====logical left shift==== | ====logical left shift==== | ||
A bitwise operation that moves all bits in an operand to the left by a specific number of positions. What does this mean? In C, we use << to represent a left shift of one place. We could also do <<# to left shift that specific number of places. In practice, this would shift the ones place to the twos place, the twos place to the fours place, the fours place to the eights place, and so on so fourth. In the context of this project, when used in a loop, this operation would allow us to perform sequential operations on a specific value of multiple bits by successively shifting the value one place to the left with each loop. | A bitwise operation that moves all bits in an operand to the left by a specific number of positions. What does this mean? In C, we use << to represent a left shift of one place. We could also do <<# to left shift that specific number of places. In practice, this would shift the ones place to the twos place, the twos place to the fours place, the fours place to the eights place, and so on so fourth. In the context of this project, when used in a loop, this operation would allow us to perform sequential operations on a specific value of multiple bits by successively shifting the value one place to the left with each loop. |