I did this code only for learning purpose. But while doing so I found a problem. Here x is constant integer,still compiler is giving me error. I am using gcc compiler. Please explain what is the reason of this error and how to avoid it.
#include<stdio.h>
int main()
{
int const x = 10;
int y = 20;
switch(y)
{
case x: //error: case label does not reduce to an integer constant
printf("value of x: %d\n",x);
break;
}
}