Skip to content

Max of two

C++ if / else

Flowchart (ISO 5807)

YesNoStartInput a, ba > bReturn aEndReturn bEndFigure 1 — maxOf

Source code

C++
int maxOf(int a, int b) {
    if (a > b) {
        return a;
    } else {
        return b;
    }
}

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

Language
C++
Constructs
if / else
Topic
Branching
Formats
Word, Visio, draw.io, PDF, SVG

Related examples