hi Aliya i think the two codes will give the same result -this is as i tried it- as m++ means: the operation will first be done and then the increase by one will occur ++m means:the increasing by one will occur and then the operation will will be done by substituting by this 1- v=0+5+(1+(5+1))=12 2-v=5+(1+(5+1))=12 as 0+ anything =anything Thanks Eng A.Mahmoud eng_hamada2585@ yahoo.com eng.hamada2585@ gmail.com
OR send your asks to ah_...@yahoogroups. com http://sites. google.com/ site/eng7amadapr ogramming/ http://tech. groups.yahoo. com/group/ eng_7amada_ for_programming_ works/ --- On Wed, 5/27/09, Aliya Awais <[email protected]> wrote: From: Aliya Awais <[email protected]> Subject: [c-prog] confusing output To: [email protected] Date: Wednesday, May 27, 2009, 2:07 AM hi ! can someone please tell me the difference between output of given two expression in C++ programs , how expressions are evaluated in these two cases? #include<iostream. h> void main() { int m=5,v=0,u=0; v=v+(m++)+(+ +m); cout<<v<<endl; //output is 11 } #include<iostream. h> void main() { int m=5,v=0,u=0; v=(m++)+(++m) ; cout<<v<<endl; //output is 12 (why confusing) } what is difference between v=v+(m++)+(+ +m); and v=(m++)+(++m) ; . thanks [Non-text portions of this message have been removed] [Non-text portions of this message have been removed]
