Error: case label does not reduce to an integer constant in C
This is an example of switch case in C programming language, switch case is used to check/jump on matched case value and then it executes given statement in the case block.
In the switch case statement, a case can only have integral constant values i.e. integer or character type constant value. We cannot use any variable as case value.
In this example, we are using case b: and b is a variable. Thus, error case label does not reduce to an integer constant occurs.
Example:
Output
How to fix?
To fix the error case label does not reduce to an integer constant, use value 2 instead of variable b. The correct statement will be case 2:
Correct code:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer