Skip to content

Minimum of three

C sequential ifs

Flowchart (ISO 5807)

YesNoYesNoStartInput a, b, cm = ab < mm = bc < mm = cReturn mEndFigure 1 — minOfThree

Source code

C
int minOfThree(int a, int b, int c) {
    int m = a;
    if (b < m) {
        m = b;
    }
    if (c < m) {
        m = c;
    }
    return m;
}

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

Language
C
Constructs
sequential ifs
Topic
Branching
Formats
Word, Visio, draw.io, PDF, SVG

Related examples