Post

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 StatementsSyntax
If-elseIf condition
else if condition
else if condition
else condition
Switch Caseswitch(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.
IterationsSyntax
For Loopfor (var i = 1; i <=10; i++)
{
  statements…
}
Foreach Loopforeach(var number in numbers)
{
  statements…
}
While Loopwhile(condition)
{
  statements…
}
Do While Loopdo
{
  statements…
}while(condition)
This post is licensed under CC BY 4.0 by the author.