Function retuning incorrect value
Hi all, I'm revising for my intro to computing class short-test two, and going through a previous year paper, I attempted to solve this function on paper, and the answer I got on paper for a was 6, but when I run the program and print a, it yields a value of 3. What am I doing wrong here? Please and thank you, any feedback is welcomed.
the exact question was this
void foo (int x, int & y)
c = x + y;
y = 2 * c;
x = 2 * x;
In the main program, if you have the following code:
int a = 3, b = 3;
What is the value of the variable “a” after “foo” is called (and executed) in the main program as above
What exactly am I doing wrong here?