you declared m as 5 and v as 0 and as you run your program v=o, m=5 and both
will become 0+(5+1)+(1+5)
this is due to increment operator together both will give the ans 12


On 5/27/09, Aliya Awais <[email protected]> wrote:
>
>
>
> 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]
>
> 
>



-- 
shruti dixit


[Non-text portions of this message have been removed]

Reply via email to