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.
case 1||2:
Becomes true. so it becomes case 1: but the passed value is 2. so default case executed. After that your printf("I thought somebody"); executed.  
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With