Skip to main content
CS Teaching Tips

Main navigation

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

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.

More about this tip

Tags

  • Content Misconceptions
  • CS 1
  • Intro Programming
  • Programming Concepts
External Source

"Visual program simulation in introductory programming education" by Juha Sorva, from Appendix A: Misconception Catalogue

Other Tips By
Other Tips By Juha Sorva

Similar tips

Misconception: Students struggle with the jump from writing code in one method to writing code in two methods.
Use programming spreadsheet functions as an introduction to programming to give students a simple but powerful mechanism for writing basic programs.
Misconception: Students have difficulty working with temporary variables in arrays.
  • CSTT Facebook
  • CSTT Twitter

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

Privacy Policy

  • National Science Foundation
  • Sage Fox Group
  • Harvey Mudd College