The arguments in printf are evaluated from right to left.
first ++a gives 11 , then a is 11 and a++(bcoz postfix) is also 11
But the final value is copied to the prefix argument (++a) and just 'a'.
The postfix argument(a++) will retain the value it obtained.
On Sat, Jun 16, 2012 at 3:49 PM, rvkmr
If you evaluate the expressions from right to left and print the result
from left to right , it will be clear.
On Thursday, June 14, 2012 11:41:04 AM UTC+5:30, Ajesh js wrote:
>
> main()
> {
> int a=10,b=5;
> printf("%d %d %d\n",a++,a,++a);
> printf("%d %d %d\n",++b,b,b++);
> }
although we know this is compiler dependent , but still such questions are
very frequent in some local competitions and can be found in some old
books too.
is it possible to have such questions in any company placement paper
or interview ?
On Thursday, 14 June 2012 11:41:04 UTC+5:30, Ajesh js