0

I am just watching a Geeks for geeks video, in that video it has been said that first all the actual parameters are evaluated and only after that they are assigned to the formal parameters. Now, while experimenting in C++, i saw a really ambiguous thing. Please see my both codes

#include <iostream>

using namespace std;

void fun(int x, int y, int z) {
    cout << x << y << z;
}

int main()
{
    int i = 2;
    fun(++i, ++i, ++i);
    return 0;
}

2nd code

#include <iostream>

using namespace std;

void fun(int x, int y, int z) {
    cout << x << y << z;
}

int main()
{
    int i = 2;
    fun(i++, i++, i++);
    return 0;
}

The 1st code is giving output as :- 555 The 2nd code is giving output as :- 432

Now, what is the order of assignment. Please explain.

0 Answers0