The following code supposed to print true. But it is printing false. Does anyone know why is it so?
int main(void)
{
int a=15,b=10, c=1;
if(a>b>c)
{
printf("true");
} else
{
printf("false");
}
}
The following code supposed to print true. But it is printing false. Does anyone know why is it so?
int main(void)
{
int a=15,b=10, c=1;
if(a>b>c)
{
printf("true");
} else
{
printf("false");
}
}
In C, a>b>c
means (a>b)>c
. It does not mean (a>b)&&(b>c)
.
The value of a>b
is either 0 or 1 (false or true, respectively). Since c
is 1, neither of those possible values can be greater than c
, so the comparison is always false.