I've been weirded out with this example I stumbled upon in my courses of C language, normally it should be incrementing nb_chiffres everytime c happens to be a digit (it's like a loop in which everytime we put c = getchar();
) and increment nb_non_chiffres when it's otherwise.
My problem is that cases do not end in ";" nor do they end in "break;" so I see it as if case '1' is included in case '2' and case '3' in '2' etc..
and I don't see the program working as intended. I know if case '0' is not true
it will execute all cases below save for default
but why didn't my teacher put the ";" at the end of the cases? Here's the code
switch(c){
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
nb_chiffres++;
break;
default:
nb_non_chiffres++;
}