does the command gets executed from left to right or right to left?
Order of execution of command
hey mayank, it will be left to right.
ans= factorial(n)/(factorial®*factorial(n-r));
first factorial(n) is called
than (factorial® is called
and than factorial(n-r)
Please help me understand above link’s code then.
Hii mayank
Your doubt is genuine as anybody gets confused in such cases. Remember that when we are storing value in a variable or returning it,then statements go left to right.
If we are doing a cout<< then statements are executed right to left.
If you still have doubt then you can check for b=a++ + a++. It will be clear to you.
I get what you say but I’m unable to understand output value for ‘b’.
In the case I told you the value of b would be 3 . Is this your question?
but the value is 5. also look that a=;
a=1; b=++a + a++; from left to right execution, a is first incremented to 2 and later it is also used as 2(for a++), so the output should be 4.
I was telling 3 as the answer of this.
For your doubt, as you are assigning answer to b it is because unary operator will have higher precedence
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.