int x;
int fun1()
{
x=x+10;
return x;
}
int main()
{
x=5;
cout<<x;
cout<<fun1();
}
this produces 5 and 15 while
cout<<x<<fun1();
this produces 15 and 15. Please explain. Thankyou
int x;
int fun1()
{
x=x+10;
return x;
}
int main()
{
x=5;
cout<<x;
cout<<fun1();
}
this produces 5 and 15 while
cout<<x<<fun1();
this produces 15 and 15. Please explain. Thankyou
In c++ reference, order of evaluation of arguments of std::cout
is unspecified. It is not left-to-right, right-to-left, or anything else.
Please avoid this. Instead use separate calls.