the thing is

Condition if(a,b,x,y)
is evaluated by the last variable present in it bcoz Comma Operator return
the last variable or constant present in it.....

give y some other value than 0 you will see the difference

--


Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad




On Fri, Aug 12, 2011 at 1:51 PM, sirshak das <rishi.godfat...@gmail.com>wrote:

> if it were if(a,b,y,x) then output wud hav been EXAM
>
>
> On Fri, Aug 12, 2011 at 4:14 AM, Prakash D <cegprak...@gmail.com> wrote:
>
>> @anuj kumar: try this
>>
>>     #include<stdio.h>
>>     #include<string.h>
>>     int main()
>>    {
>>    int a=10,b=20;
>>    char x=1,y=0;
>>    printf("%d\n",a,b,x,y);
>>    printf("%d\n",(a,b,x,y));
>>
>>    if(a,b,x,y)
>>    {
>>       printf("EXAM");
>>    }
>>    getchar();
>>    }
>>
>> this will print 10 and 0
>> because if the outer bracket is not there, only the first element is
>> considered it ignores the rest. if there is a bracket it just pushes into
>> the stack left to right and the last element is considered..
>>
>> within if, there is no outer brackets but it tries to convert to bool and
>> statement will execute like "if((bool)(a,b,x,y))"
>> so the if condition fails
>>
>> correct me if i'm wrong
>>
>> On Thu, Aug 11, 2011 at 5:18 PM, sukran dhawan <sukrandha...@gmail.com>wrote:
>>
>>> the output should be blank. because comma is a operator in c which
>>> associates from left to right. so each of a ,b,x,y is evaluated and y is the
>>> last one to be evaluated and its value(0) is returned as the value of the
>>> expression.so the if condition returns false.
>>> i dont understand how u got that output !
>>>
>>>
>>> On Thu, Aug 11, 2011 at 4:29 PM, Prem Krishna Chettri <
>>> hprem...@gmail.com> wrote:
>>>
>>>> Yep,
>>>>
>>>>   Ideally, if() statement evaluates the last push stack value from the
>>>> stack and apparently here the last value evaluates to be 0 resulting the
>>>> failure of the if condition.
>>>>
>>>> Please verify the compilation. :)
>>>>
>>>> Prem
>>>>
>>>>
>>>> On Thu, Aug 11, 2011 at 4:21 PM, hary rathor <harry.rat...@gmail.com>wrote:
>>>>
>>>>> print nothing , your output is wrong
>>>>>
>>>>>  --
>>>>> 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.
>>>
>>
>>  --
>> 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.
>>
>
>
>
> --
> Rishi
>
>
>
>  --
> 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.

Reply via email to