Skip to main content
Engineering LibreTexts

5.2: Program Flow Control

  • Page ID
    86640
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Command Effect

    break 

    Terminates execution of a loop.

    case 

    Provides alternate execution paths within switch structure.

    else 

    Delineates alternate block of statements.

    elseif 

    Conditionally executes statements.

    end 

    Terminates for, while, and if statements.

    error 

    Display error messages.

    for 

    Repeats statements a specific number of times

    if 

    Executes statements conditionally.

    otherwise 

    Default part of switch statement.

    return 

    Return to the invoking function.

    switch 

    Directs program execution by comparing point with case expressions.

    warning 

    Display a warning message.

    while 

    Repeats statements an indefinite number of times.


    5.2: Program Flow Control is shared under a CC BY 1.3 license and was authored, remixed, and/or curated by Brian Vick, Virginia Tech.

    • Was this article helpful?