Remind students that variable assignment occurs in the order assignments are given. This avoids the misconception that changing one value affects other variables assigned before it.
Share Remind students that variable assignment occurs in the order assignments are given. This avoids the misconception that changing one value affects other variables assigned before it. with FacebookShare Remind students that variable assignment occurs in the order assignments are given. This avoids the misconception that changing one value affects other variables assigned before it. with Twitter
- E.g.,
count1 = 3;
count2 = 2;
sum = count2 + count1;
count1 = 4;
In this example, the value ofsumis 5 because the variablesumhas not been redefined or reassigned. The variablesumwill retain its value of 5 until it is assigned another value.