To add to what @Yanson said. You're sending in a copy of the variable y. Then you're making the variable y into the number 2. But the original never left, you havent touched it. You have to pass it by reference, which is when you pass in the original and it should work -