Skip to content

Max in an array

C largest element

Flowchart (ISO 5807)

YesNoStartInput a[], nm = a[0]i = 1, n − 1, 1a[i] > mm = a[i]Return mEndFigure 1 — maxOf

Source code

C
int maxOf(int a[], int n) {
    int m = a[0];
    for (int i = 1; i < n; i++) {
        if (a[i] > m) m = a[i];
    }
    return m;
}

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

Language
C
Constructs
largest element
Topic
Loops
Formats
Word, Visio, draw.io, PDF, SVG

Related examples