Pass-by-Reference

The objective for today's short lab is to investigate the difference bewteen pass-by-value and pass-by-reference.

  1. Create a New Project
  2. The code for today's lab requests two numbers from the user and swaps the numbers. The swap function is supposed to modify the variables in the main program.
  3. Paste the following code
  4. Run the code
  5. The program does not modify the variables in the main program since it uses pass-by-value.
  6. Modify the program to be pass-by-reference
  7. Place the text of your code into the Lab 6 dropbox

Now that you have completed this lab, modify your functions for your project to have pass-by-reference

First, look at the "Vend()" function that receives the product number, returns the cost of a product, and needs to decrement the numChips, numCookies ,...
Make the product amounts pass-by-reference.

Next, look at the function that accepts coins.
The function should pass the number of quarters, dimes, nickels as "reference"

What other functions need pass-by-reference? Perhaps the calculate change function? Are there others?