Switch case MCQ 17: Negative Case Labels are allowed

February 8, 2025 No Comments » Hits : 148





Switch case MCQ 17: Negative Case Labels are allowed


Problem Statement 17 : Negative Case Labels are allowed

void main()
{
 int choice = -2 ;
   switch(choice)
   {
   case -1:
         printf("\nCase -1");
         break;
   case -2:
         printf("\nCase -2");
         break;
   }
}

Options : Is it necessary to have Case Labels greater than Zero

  1. Yes
  2. No

Output
No

No


How ? Why ?

  1. Generally Case Label Should be Integer / Constant
  2. Negative numbers having no decimal point are also considered as Integer
  3. Thus it is not necessary to have Case Labels greater than Zero

Incoming search terms: