It is because you are using variable in you code.You can't use a variable in case statement.
Here a is assumed as variable
The compiler is explicitly allowed to use an efficient binary tree or
a jump table to evaluate case statements.
For this reason, case statements are compile time constants.
The C99 standard says this (and the C89 standard was very similar):
§6.8.4.2 The switch statement
Constraints
¶1 The controlling expression of a switch statement shall have integer
type.
[...]
¶3 The expression of each case label shall be an integer constant
expression and no two of the case constant expressions in the same
switch statement shall have the same value after conversion. There may
be at most one default label in a switch statement.