@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 <[email protected]>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
> <[email protected]>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 <[email protected]>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 [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.
>>>
>>
>> --
>> 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.
>>
>
> --
> 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.
>
--
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.