Skip to content

Day of week

C++ switch + default

Same task in: GoRust

Flowchart (ISO 5807)

YesNoYesNoYesNoStartInput dd = 1Return «Пн»Endd = 2Return «Вт»Endd = 3Return «Ср»EndReturn «?»EndFigure 1 — day

Source code

C++
const char* day(int d) {
    switch (d) {
        case 1: return "Пн";
        case 2: return "Вт";
        case 3: return "Ср";
        default: return "?";
    }
}

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

Language
C++
Constructs
switch + default
Topic
Switch / case
Formats
Word, Visio, draw.io, PDF, SVG

Related examples