New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Will anyone explain this programme??
2 Answers
+ 4
The function 'x' accepts two by integer parameters by reference, meaning it can directly alter their values.
https://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/
It then changes the value of the first parameter 'a' to 3 and the value of the second parameter 'b' to 4, and finally returns the value of 'a', which is now 3.
In main(), we pass the variables 'b' and 'a' into the function, so that 'b' becomes 3 (it corresponds to the function parameter 'a', since it is passed first - the naming might be confusing here) and 'a' becomes 4. The variable 'c' is then assigned the return value of the function, which is always 3.
As a result, the output is 433.
0
ooutput is 2 7 3