Inside switch statement nothing will be accepted like assigning values to the variable and printing except inside case. if you want the b value assign it outside the switch . Also b value should be like garbage value it can't change until assign some values to the particular location.