Hi guys. So, I'm really new at this programming thing. I'm taking a class right now and in one of the assignments, we are supposed to create a void function that adds 5 to the value that is passed to the function. I can only change the part that is between //s. I thought what I did was right, but the output is exactly the same as the input, so it's not adding 5. Can you help me figure out what I'm doing wrong?
Whats happening in your program right now is that those 3 numbers are passed to the addfive function. Then 5 is added to each of those function. However, the couts in the main function are outputting the ORIGINAL number1, number2, and number3, NOT the modified ones. The modified ones are still in the addfive function. This is because the parameters you sent to the addfive function were merely COPIES and not the actual variables.
To send the actual variables, simply put an ampersand (&) sign after each 'int' of the parameter types.
so: void addFive(int& number1, int& number2, int& number3)