Switch case MCQ 20 : Floating Numbers are not allowed

February 8, 2025 No Comments » Hits : 65






Switch case MCQ 20 : Floating Numbers are not allowed


TAGS :

  1. Does Floating Point numbers allowed in switch case ?
  2. Floating Point in Switch Label !!!

Problem Statement 20 : Floating Numbers are not allowed

void main()
{
 float choice = 10.1 ;
 switch(choice)
  {
  case 10.1 :
            printf("\nCase 10.1");
            break;
  case 10.2 :
            printf("nCase 10.2");
            break;
  case 10.3 :
            printf("nCase 10.3");
            break;
  }
}

Options : Is it working properly ?

  1. Yes
  2. No

Output
No

How ? Why ?

  • Case Labels won’t allow you to use Floating Number