Function Practice: Printing a range of numbers, now with parameters!

The goal for this exercise is to make sure that you can create and use basic functions, and that you can pass information to those functions using parameters/arguments.

What you need to do to prepare for this exercise:


In the starter project, fill in the Number_Printing_With_Parameters.RunExercise method. This method will call a method that you create, named PrintNumbers (which you must put in the class named NumberPrinter). PrintNumbers will use a loop to print out all the integers between X and Y, where X is the first argument to the method, and Y is the second. In order to do this, you will probably want to declare (at least) one local variable in PrintNumbers. Note that in this exercise, you are not required to ask the user for any information about which numbers to print – when testing your function using the RunExercise method, feel free to simply write the numbers directly into the code.

Make sure that you understand when the local variable is first created, and ceases to exist. Try tracing the code mentally and with paper, and while you’re tracing the code, draw/erase boxes to represent all the local variables, including the parameters. Try to use PrintNumbers ' variable(s) within PrintNumbers, and within Main, and see which ones work.

What you need to do for this exercise
  1. In the starter project, uncomment the Number_Printing_With_Parameters.PrintNumbers method, and fill in both that and the NumberPrinter class so that they behave as described above.