Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Member List
Calendar
Today's Posts
Home
Forum
Topic
C
What is the execution sequence for the code (x = i++ + ++i) ?
What is the execution sequence for the code (x = i++ + ++i) ?
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
robertcullen
New Member
Join Date:
Aug 2010
Posts:
4
#1
What is the execution sequence for the code (x = i++ + ++i) ?
Aug 21 '10, 08:48 PM
main()
{
int i=1;
int x;
x=i++ + ++i;
printf("%d",x);
}
donbock
Recognized Expert
Top Contributor
Join Date:
Mar 2008
Posts:
2427
#2
Aug 21 '10, 09:05 PM
Strange how this question has arisen so many times recently. Look
here
and
here
and
here
.
Comment
Post
Cancel
robertcullen
New Member
Join Date:
Aug 2010
Posts:
4
#3
Aug 21 '10, 09:43 PM
I want to know how compiler compile this code?
In which sequence it is going to execute.
firstly "i++" or "++i".
Its Associativity?
Comment
Post
Cancel
donbock
Recognized Expert
Top Contributor
Join Date:
Mar 2008
Posts:
2427
#4
Aug 21 '10, 11:20 PM
This is a trick question; nobody can answer it. The explanation is in those links I gave you in my first reply.
I'm curious why you're asking about this.
Comment
Post
Cancel
code green
Recognized Expert
Top Contributor
Join Date:
Mar 2007
Posts:
1726
#5
Aug 23 '10, 02:03 PM
I suggest it is clever question set by a tutor as an assignment,
to test the students understanding of compiler logic.
So an explanation of why it is impossible to answer is what the tutor is looking for.
Comment
Post
Cancel
Previous
template
Next
Working...
OK
OK
Cancel
👍
👎
☕
Comment