Kodewick
Start learning →
Basic←0 / 86

Days in the Month

#086Basiccase 4: case 6: …4 min

Show how many days a month has: long months 31, short months 30, and February counted as 28. The 31-day months and February are written — add the 30-day ones: 4, 6, 9 and 11. This month is 4.

Should show
30
main.cpp
#include <iostream>
using namespace std;

int main() {
    int month = 4;
    switch (month) {
        case 1: case 3: case 5: case 7: case 8: case 10: case 12:
            cout << 31 << endl;
            break;
        // your code here: show 30 for months 4, 6, 9 and 11
        case 2:
            cout << 28 << endl;
            break;
    }
    return 0;
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.