• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

What does evaluation mean? post, pre ++ --

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Could anybody make me understand what does evaluation mean? It is said, the expression is first evaluated from left to right ... Is value is put at the time of evalution. Give a example please.
Little descriotion would be appreciated.


Thanks and Regargs,
cmbhatt
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An opration like variable++ would change the value of the variable in the next line. An operation like ++variable will change the value of the variable immediately on the same line.

int x=0;
x++; - value of x is 1 in the next line
int y=0;
++y; - value of y is 1 here
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks John,

Does next line increment also include the same line in postfix while there are sevaral post increment operaions like:

int x=1;
int y= x++ + x++ + ++x + x++;


Please clarify, how will the above expression be "evaluated"?

Thanks and Regards,
cmbhatt
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its very important to make it clear

x = 3

y = x ++ ; // y = 3 ;
y = ++ x ; // y = 4 ;

value wont be incremented in the first expression but in the second it will be incremented first and then assigned to x.


hope it helped
chintan
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chandra Bhatt:
...how will the above expression be "evaluated"?



 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Marc,

The way you answered was what I expected.




Thanks and Regards,
cmbhatt
 
It's feeding time! Give me the food you were going to give to this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic