if z= ++i + ++i // where i=2 initially then z= 4+4 =8

On Tue, Jul 19, 2011 at 10:23 AM, kaustubh <[email protected]> wrote:

> z is equal to 6 as both are post increment. However, if one of these
> was pre-increment, output would have been undefined.
>
> On Jul 19, 9:39 am, sagar pareek <[email protected]> wrote:
> > you are using post increment which increments th evariable in next line
> :)
> > (except for the case of printf();
> >
> > so here z=x++ + x++ will give you z=3+3
> > and the two post increment will give you x+=2
> >
> > i hope toy get it )
> >
> > On Tue, Jul 19, 2011 at 8:17 AM, Vengadanathan <[email protected]
> >wrote:
> >
> >
> >
> >
> >
> > > this is the program ,
> > > #include<stdio.h>
> > > int main()
> > > {
> > > int z=0,x=3;
> > > z = x++ + x++;
> > > printf("%d %d",z,x);
> > > return 0;
> > > }
> >
> > > i though the output would be 7,5 , but when i ran the code it was
> > > 6,5 , can anyone tell me how this o/p is obtained .
> > > thanx in advance
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.
> >
> > --
> > **Regards
> > SAGAR PAREEK
> > COMPUTER SCIENCE AND ENGINEERING
> > NIT ALLAHABAD- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
**Regards
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
NIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to