This Repo required for Asac labs class 2
loop is a programming structure that repeats a sequence of instructions until a specific condition is met. Loops check a condition. If it returns true, a code block will run. Then the condition will be checked again and if it still returns true, the code block will run again. It repeats until the condition returns false.
in below a flowchart of loop:
There are three common types of loops:
For Loop: If you need to run code a specific number of times, use a . is the most common loop.) In a for loop, the condition is usually a counter which is used to tell how many times the loop should run.
While Loop: If you do not know how many times the code should run, you can use a while loop. Here the condition can be something other than a counter, and the code will continue to loop for as long as the condition is true.
do…while: loop is very similar to the while loop, but has one key difference: it will always run the statements inside the curly braces at least once, even if the condition evaluates to false.
## Operatores ro Evaluate the condistions :
< less than
>greater than
<= less than or equal to
>= greater than or equal to
== equal to
!= not equal to
=== strict equal
!== not strict equal
There are three main expressetions in the condtions which are:
LOGICAL AND This operator tests more than one condition. ((2 < 5) & (3 >- 2)) returns true If both expressions evaluate to true then the expression returns true. If just one of these returns false, then the expression will return false.
true && false returns false
false & true returns false
false && false returns false
LOGICAL OR This operator tests at least one condition. ((2 < 5) | (2 < 1)) returns true If either expression evaluates to true, then the expression returns true. If both return false, then the expression will return false. | |
- true | true returns true |
true | false returns true |
false | true returns true |
false | false returns false |
LOGICAL NOT This operator takes a single Boolean value and inverts it. (T > 2)1 returns true This reverses the state of an expression. If it was false (without the ! before it) it would return true. If the statement was true, it would return false.
Itrue returns false
Ifalse returns true