@azharr
+1 .... i got the concept ... thnxsss

On Mon, Feb 13, 2012 at 8:25 PM, Manikanta Babu
<manikantabab...@gmail.com> wrote:
> Azhar,
>
> Thanks for the answer. Its a great explanation.
>
> Cheers,
> Mani
>
> On Mon, Feb 13, 2012 at 7:50 PM, Azhar Hussain <azhar...@gmail.com> wrote:
>>
>> C, standard says which operand belongs to which operator. It does not says
>> which one gets evaluated first.
>> Why it is returning 8 is because of sequence point. It tells that, all the
>> side effects of a value are resolved before an operation is performed.
>> In your case ++i + ++i evaluates like this on gcc 4.2
>>           ++2 which is 3
>>           ++3 which is 4
>> now sequence point is resolved both i + i is added to yield 8.
>> You should not use such expression
>>
>> More information can be found at
>> http://c-faq.com/expr/seqpoints.html
>> http://en.wikipedia.org/wiki/Sequence_point
>>
>> -
>> Azhar.
>>
>>
>> On Mon, Feb 13, 2012 at 7:38 PM, Ratan <success.rata...@gmail.com> wrote:
>>>
>>> Actually i had evaluated x=(++i + ++i); separately with i=2;
>>> but i was amazed to get answer as 8... can u elaborate it
>>>
>>> On Mon, Feb 13, 2012 at 4:09 PM, Rahul <raikra...@gmail.com> wrote:
>>> > Here you go then :
>>> > ++ i becomes 3
>>> > second bracket becomes 5 ( 3+2)
>>> >
>>> >
>>> > first bracket is 4
>>> >
>>> > 4 * 5 = 20
>>> > But you are adding ONE to i FOUR times
>>> > hence the answer you get is 4 plus the computation of previous line
>>> >
>>> > Hope I AM correct :
>>> >
>>> >
>>> >
>>> >
>>> > On Mon, Feb 13, 2012 at 3:56 PM, Ratan <success.rata...@gmail.com>
>>> > wrote:
>>> >>
>>> >> can any1 explain the working of the above expression in any of the
>>> >> compiler..... I jzz want to knw how the computation takes place in gcc
>>> >> compiler..
>>> >>
>>> >> On Sun, Feb 12, 2012 at 11:03 PM, Kartik Sachan
>>> >> <kartik.sac...@gmail.com>
>>> >> wrote:
>>> >> > its a compiler depentent...
>>> >> >
>>> >> > --
>>> >> > 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.
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> --
>>> >> Ratan | 3rd Year | Information Technology | 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 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.
>>>
>>>
>>>
>>> --
>>> --
>>> Ratan | 3rd Year | Information Technology | 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 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.
>
>
>
>
> --
> Thanks & Regards,
> Mani
> http://www.sanidapa.com - The music Search engine
>
> --
> 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.



-- 
--
Ratan | 3rd Year | Information Technology | 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 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