Skip to main content
CS Teaching Tips

Main navigation

  • Browse All Tips
  • Tags
  • 3D
  • About
  • Rate Tips
  • Tip Sheets

Random Tip

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 of sum is 5 because the variable sum has not been redefined or reassigned. The variable sum will retain its value of 5 until it is assigned another value.

For more information or to report a bug, contact us at admin@csteachingtips.org. Built with Bootstrap. Powered by Drupal.

Privacy Policy