Skip to content

Ternary operator

C++ ?: → branching

Flowchart (ISO 5807)

YesNoStartInput xx < 0Return −xEndReturn xEndFigure 1 — absVal

Source code

C++
int absVal(int x) {
    return x < 0 ? -x : x;
}

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

Language
C++
Constructs
?: → branching
Topic
Branching
Formats
Word, Visio, draw.io, PDF, SVG

Related examples