Skip to main content
CS Teaching Tips

Main navigation

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

Compare loops to climbing a flight of stairs to give students a model for how for loops work in real life.

Share Compare loops to climbing a flight of stairs to give students a model for how for loops work in real life. with FacebookShare Compare loops to climbing a flight of stairs to give students a model for how for loops work in real life. with Twitter
  • If you’re climbing steps from one level to the next level, you can choose the increment based on how many steps you take at a time.
    • You can choose to go up the stairs one step at a time: for(int i = 0; i<100; i++)
    • You can choose to go up the stairs two steps at a time: for(int i=0; i<100; i = i + 2)
    • Or, to represent going down the stairs one step at a time: for(int i=100; i>0 i--)

More about this tip

Tags

  • Java
  • Programming Concepts
External Source
Interview with Chinma Uche
Other Tips By
Other Tips By Chinma Uche

Similar tips

Spend extra time teaching Big O in intro classes that use Python because the underlying implementation of Python lists is a mystery to students that leads students to believe many operations are constant, O(1), that are not.
Show students examples of infinite loops in Alice using Do-together and Do-in-order blocks with the goal of furthering students’ understanding and recognition of for loops.
Demonstrate manipulating primitives with operators before manipulating them with methods so students can understand the basics of primitives before using them in a more complicated way.

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

Privacy Policy