Bookmark Topic Watch Topic
  • New Topic

Evaluation of Operators  RSS feed

 
Mani Pava
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please try this piece of code in JAVA and C++, and you will get two different answers...

java code {

int j = 0 ;
int k = 5 ;
j = k++ + --k;
System.out.println(j) ;
System.out.println(k) ;

}

cpp code {

int j = 0 ;
int k = 5 ;
j = k++ + --k ;
cout << j ;
cout << k ;

}

Answers:
JAVA : j=10, k=5
CPP : j=8, k=5


Please explain....

Thanks in Advance,
Mani
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place. Please read this for more information.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!