# end

## Purpose

Terminate `for`, `while`, and `if` statements.

## Synopsis

    while expression
        statements
    end

    if expression
        statements
    end

    for expression
        statements
    end

## Description

`end` terminates the scope of `for`, `while`, and `if` statements. Without an `end` statement, `for`, `while`, and `if` wait for further input. Each `end` is paired with the closest previous unpaired `for`, `while`, or `if` and serves to delimit its scope.

## Examples

This example shows `end` used with `for` and `if`. Indentation provides easier readability.

    for i = 1:n
        for j = 1:n
            if i == j
                a(i,j) = 2;
            elseif abs(i;j) == 1
                a(i,j) = 1;
            else
                a(i,j) = 0;
            end
        end
    end

## See Also

    break, for, if, return, while

(c) Copyright 1994 by The MathWorks, Inc.