I have this code below and was wondering why the outcome of the cout becomes 576. I worked it step by step and ended up with 654. I got the first line right the first time you call the function f(x,y,z) and got 356, but after that I'm completely lost. Could someone please explain to me in detail line by line when calling the function f and how its calculated?
#include <iostream>
usingnamespace std;
void f(int a, int &b, int &c)
{
a++; b++; c++;
}
int main()
{
int x = 3;
int y = 4;
int z = 5;
f(x,y,z);
f(x,x,y);
f(z,y,x);
cout << x << y << z;
system ("pause");
return 0;
}
#include <iostream>
usingnamespace std;
void f(int a, int &b, int &c)
{
a++; b++; c++;
}
int main()
{
int x = 3;
int y = 4;
int z = 5;
f(x,y,z); //x=3, y=5, z=6
f(x,x,y); //x=3, x=4, y=6
f(z,y,x); //z=6, y=7, x=5
cout << x << y << z;
system ("pause");
return 0;
}