The problem is in your
case 5:
block.
If you change
int cnt=0;
to
int cnt;
cnt = 0;
the problem goes away. Basically, the compiler re-organizes your code so that the
int cnt;
declaration occurs before the switch statement.
The other way you can fix this is to enclose the entire contents of this particular case satement inside it's own block.
i.e
case 5:
....
....
....
break;
case 6:
....
....
becomes
case 5:
{
....
....
....
}
break;
case 6:
....
....