- #1
the_kool_guy
- 37
- 0
Homework Statement
initially i = 10;
Homework Equations
1) x = i++ + i++
2) x = ++i + ++i
3) x = i++ + ++i
4) x = ++i + i++
5) x= i++ + ++i + i
6) x= ++i + i++ + i
The Attempt at a Solution
i++ is post incrementation while ++i is pre incrementation
by this logic i know ans of eqn 1) is 20.but other equations gets me wrong
by gcc, answers to 2),3),4),5),6) are 24,22,22,33,33 .
i am getting no idea how this thing works.
somehow i am able to think of a way to answer above but situation gets worse in case of
x = i++ + ++i + i++ + ++i;
and x= ++i + i++ + ++i + i++;
where answers are 45 and 46.
this whole thing is screwing me up
pls help
thanks