Skip to content

Symmetric matrix check

C++ nested loops

Flowchart (ISO 5807)

YesNoStartInput a[][10], ni = 0, n − 1, 1j = 0, n − 1, 1a[i][j] ≠ a[j][i]Return falseEndReturn trueEndFigure 1 — isSymmetric

Source code

C++
bool isSymmetric(int a[][10], int n) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i][j] != a[j][i]) {
                return false;
            }
        }
    }
    return true;
}

The editor opens with this code — change it and the chart redraws.

Language
C++
Constructs
nested loops
Topic
Loops
Formats
Word, Visio, draw.io, PDF, SVG

Related examples