+ 2
Can you explain about the output of this code?
2 Answers
+ 2
"The order of evaluation of arguments is unspecified. All side effects of argument expression evaluations take effect before the function is entered. The order of evaluation of the postfix expression and the argument expression list is unspecified"
Source: https://stackoverflow.com/questions/621542/compilers-and-argument-order-of-evaluation-in-c?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
+ 2
first remember that..
the very first priority
of all.
is. pre operators
pre fix operators having 1st priority ..
post fix operators has priority less than equal "=".
Start from right to left
if you come across
-->>a++
increment at next statement
-->++a
increment at same statement
for example
#include <iostream>
using namespace std;
void Test(int a,int b ){
cout <<a<<endl<<b<<endl;
}
int main()
{
int x{0};
Test(x++,x++);
. 1 0 <----
but if you print x i.e 2
remember above re
return 0;
}
#include <iostream>
using namespace std;
void Test(int a,int b ){
cout <<a<<endl<<b<<endl;
}
int main()
{
int x{10};
Test(x++,x++);
. // 14. 13-<<---
remember above point of pre fix
//output come
is 14. and 14..
return 0;
}
I hope you understand well..
if you not ,sked me again..
we all are happy to ans you