Control Flow
Control Flow and Iterations
- The flow of execution refers to the order in which the code of a program is executed or evaluated.
- Below are the control flow statements:
Conditional Statements | Syntax |
---|---|
If-else | If condition else if condition else if condition else condition |
Switch Case | switch(variable) { case (condition): break case (condition): break Default: break } |
- Iterations statements are used to loop through a block of code as long as the condition is true.
Iterations | Syntax |
---|---|
For Loop | for (var i = 1; i <=10; i++) { statements… } |
Foreach Loop | foreach(var number in numbers) { statements… } |
While Loop | while(condition) { statements… } |
Do While Loop | do { statements… }while(condition) |
This post is licensed under CC BY 4.0 by the author.