+ 1

What is the output of this code ??????

int x(int &a, int &b){ a=3; b=4; return a+b; } int main () { int a=2; int b=7; int c=x(a,a); cout<<a<<b<<c; }

25th Aug 2018, 3:28 PM
sanket charanpahadi
sanket charanpahadi - avatar
5 Respostas
+ 3
sanket charanpahadi plz check it in code playground on your own... if you get doubt in results, feel free to ask
25th Aug 2018, 5:10 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
26th Aug 2018, 5:34 AM
sanket charanpahadi
sanket charanpahadi - avatar
+ 1
sanket charanpahadi I don't think it has error.. it should output 478
26th Aug 2018, 5:05 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
sanket charanpahadi try changing function call as int c = x(a,b) and output will be 347... with these two output, try to understand the logic behind it... concept of function call pass by reference is used in this. feel free to ask if you are still confused
26th Aug 2018, 5:08 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
Ketan Lalcheta This code gives an error
26th Aug 2018, 1:59 AM
sanket charanpahadi
sanket charanpahadi - avatar