how to swap values in a function

I am trying to write a function that will take three parameters: the first two are integers that will be swapped, and the third will be a multiplier value. I am able to swap the integers but I can't figure out why it's not multiplying them by the third parameter. Can anyone help?

1
2
3
4
5
6
7
8
9
10

int swapAndMult (int& a, int& b, int multiplier)
{
    int product1, product2;
    swap (a, b);
    product1 =  a * multiplier;
    product2 = b * multiplier;
    return (product1, product2);
}
C++ isn't python.

1
2
3
4
5
6
void swapAndMult (int& a, int& b, int multiplier)
{
    swap( a, b );
    a *= multiplier;
    b *= multiplier;
}
Topic archived. No new replies allowed.