0

Could someone explain me the program flow for this step by step? I don't understand how the program enters the do-while loop in the first place as n%3=1 and Case 0 should not be entered according to my understanding. Thanks in Advance!

#include <iostream>

int main() {
    int n = 3;
    int i = 0;

    switch (n % 2) {
    case 0:
        do {
            ++i;
    case 1: ++i;
        } while (--n > 0);
    }

    std::cout << i;
}
François Andrieux
  • 28,148
  • 6
  • 56
  • 87

0 Answers0