• Post Reply Bookmark Topic Watch Topic
  • New Topic

PostFix, Prefix  RSS feed

 
Hemant Agarwal
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Output is
i = 11
j = 10
[ December 16, 2005: Message edited by: Hemant Agarwal ]
 
Sri Ram
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out this url on Postfix and Prefix Web page.
This will explain clearly why the output is like that.
 
Hemant Agarwal
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now What is this?


 
Hemant Agarwal
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Output is
i is 23
j is 22
 
Sri Ram
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this table. This should give u some ideas what prefix and PostFix does to datatypes


Operator Use Description
++ op++ Increments op by 1; evaluates to value before incrementing
++ ++op Increments op by 1; evaluates to value after incrementing
-- op-- Decrements op by 1; evaluates to value before decrementing
-- --op Decrements op by 1; evaluates to value after decrementing
 
Hemant Agarwal
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sri Ram Please tell me in detail.
Write some text. Elaborate it. What you want to say in your previous post?
I am not getting anything from that.
 
Sri Ram
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider this Example


I have written all the comments in code itself. That should explain them
The same thing happens to decrement operator also.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12564
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can also check out this page, as it's a very common question around here.
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Which operator have precedence + or ++ : It is ++.

so i = i++ + ++i can be split into the following sequence
i = lhs of plus + rhs of plus;//where lhs is i++ and rhs is ++i
lhs of plus = i; //i =10 so lhs of plus = 10
i++;//i =11
++i;//i =12
rhs of plus = 12
i = 10 + 12; //putting back the values of lhs and rhs of plus operator
[ December 01, 2005: Message edited by: jiju ka ]
 
cathymala louis
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
really nice explanation.
 
Sri Ram
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really Good.
 
Adam Richards
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tip: Try to use more specific subject lines. The more meaningful your subject, the more meaningful your replies.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!