Switch case with logical operator in C
问题 I am new to C and need help. My code is the following. #include<stdio.h> #include<conio.h> void main() { int suite=2; switch(suite) { case 1||2: printf("hi"); case 3: printf("byee"); default: printf("hello"); } printf("I thought somebody"); getche(); } I am working in Turbo C and the output is helloI thought somebody . There's no error message. Please, let me know how this is working. 回答1: case 1||2: Becomes true . so it becomes case 1: but the passed value is 2. so default case executed.