Decrement operator in different model in c/c++

main()
{
int a=8;
printf(“%d%d%d%d%d”,a++,a--,++a,--a,a);
Tutorial answer:
78878

Debugging explanation:
First it execute line from right to left.but it will print from right to left.
a++,a--,++a,--a,a;
read from left
a is 8
--a is 7
++a is 8
a—decrement operator come after the variable so first it assign then it will decrement.(see related post)8
a++.now before a - -is it decrease the value to 7

Post a Comment

0 Comments