Order of evaluation of operands is not defined in C and secondly the result
will be compiler implementation dependent. A compiler may store the sub
expressions operand values in a temporary storage or can make use of
variable value as an operand.
*In each case, either of the ++b may be executed first. *
1. If the operand values is to be stored in temporaries the first evaluation
will make one operand to be 4 and next evaluation make
the other one to be 5. So in this case the result is 4*5 = 20.
2. But if variable b is to be used as operands the result will be 5*5 = 25
As a good practice using sub expressions which modify same data object
should be avoided in an expression.
On Sat, Jun 4, 2011 at 2:23 PM, Dv!! ITs nt me now!! <
[email protected]> wrote:
> statement starts executing from the right side!!! 1st it reads it
> from left !! while reading b increment two times and new value of b is
> thn 5 nw it gets executed!!!
> am i right??
>
> On 6/4/11, hary rathor <[email protected]> wrote:
> > in 1st pass
> >
> > both ++b
> > ++b= 4 then ++b= 5;
> >
> > at second pass a= 5*5; because ++b is 5
> >
> > --
> > 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.
> >
> >
>
>
> --
> Dhruva Verma
> BTech(IT)-2nd year
> IIIT-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.
>
>
--
ROHIT SINDHU
B.Tech (IT) -- 6th sem.
INDIAN INSTITUTE OF INFORMATION TECHNOLOGY, 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.