For visual understanding,lets recall the definition of a variable:
"A variable is a memory location holding some value"

In the above question,we are discussing operations on only one variable
"b".As stated in mail below,we will be doing prefix operations first as a
general rule.when we do ++b it will increment the value at the same memory
location where previous value of b is stored.Again ++b increments the value
at same location.Hence,effectively,b is now 5.now we will multiply and get
25.Precedence of operators also assigns higher priority to ++ than *.

On Wed, Jun 1, 2011 at 9:57 PM, anuj agarwal <coolbuddy...@gmail.com> wrote:

> This will be same as:
> b=b+1;
> b=b+1;
> a=b*b;
>
> Basically, all prefix increment and decrement operators will be executed
> first. Similarly all postfix operators will be executed at last.
>
> Anuj Agarwal
> Engineering is the art of making what you want from things you can get.
>
>
>
> On Wed, Jun 1, 2011 at 5:27 PM, Vishal Thanki <vishaltha...@gmail.com>wrote:
>
>> you may want to read: http://c-faq.com/expr/seqpoints.html
>>
>> On Wed, Jun 1, 2011 at 5:19 PM, himanshu kansal
>> <himanshukansal...@gmail.com> wrote:
>> > a=++b*++b;
>> > if b=3 initially, then a is coming out to be 25.....why????
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> > To post to this group, send email to algogeeks@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>> >
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Regards,
Ashish

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

Reply via email to