@vishwa : that is not correct. Check : http://ideone.com/Kn7hRn


On Wed, Nov 7, 2012 at 9:20 PM, vishwa <vishwavam...@gmail.com> wrote:

> I guess its other way.
>
> According you guys explanation after evaluating the expression first the
> if condition turns out to be   if(1);
>
> And the program runs infinitely..
>
> first      --   ++k <= 8   ---   turns true and k becomes  6.
>
> second -- k++ / 5       ---   skipped. k remains  6
>
> third     -- ++k < 5      ---   turns false and k becomes 7.
>
>
> Hope its very clear
>
>
>
>
> On Wed, Nov 7, 2012 at 7:13 AM, apsalar <kavya...@gmail.com> wrote:
>
>> We start with k = 5.
>>
>> if ++k < 5 translates to if 6 < 5 => which is false.
>> No need to evaluate k++/5 (short-circuiting)
>> if ++k <= 8 translates to (6+1) 7 <= 8 which is true.
>> So, 7 gets printed.
>>
>>
>> On Tuesday, November 6, 2012 6:22:13 AM UTC-5, Anil Sharma wrote:
>>>
>>> main()
>>>      {
>>>       int k = 5;
>>>       if (++k < 5 && k++/5 || ++k <= 8);
>>>       printf("%d ", k);
>>>      }
>>>
>>> the output shud be 8 but it comes out to be 7.why???
>>> as increment operator has higher precedence among them so increment shud
>>> be done throughout at first and after then other operators shud be
>>> evaluated.so    output shud be 8.
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/algogeeks/-/KgsSjel6n_4J.
>>
>> 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,*
> *Vishwa*
> *+91 9964051504*
>
>  --
> 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.
>



-- 

Aamir Khan | 4th Year  | Computer Science & Engineering | IIT Roorkee

-- 
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