+ 2
What is the output of this code? Can someone please explain me this how?
void sum(int a, int b, int &c) { a=b+c; b=a+c; c=a+b; } int main() { int x=2,y=3; sum(x,y,y); cout<<x<<y; }
1 Antwort
+ 8
a=3+3=6
b=6+3=9
c=6=9=15
&c is in parameters, so it points to y. So, the value of y gets changed to 15 while x remains 2
Output:215