The below code runs a \'for\' loop to create months 1 through 12 then names each month Jan through Dec according to their number. That pieces compiles fine. At the bottom wher
You will be surely declaring monthName outside scope also(in your loop it declared again). other wise the program should tell compile error. right click on the variable then "Go to defenision". If so variables are different. so only its misbehaving
The reason is two variables having different memory in primary memory. so one memory update won't effect the other. Compiler will use maximum local variable for its processing. Inside loop its the declared one inside. Outside the loop its the outside one
So if you needn't the outer variable value further don't declare it again inside. other wise you declare it outside of the loop with some other name