#include<stdio.h>
int main(void)
{
int i=1,j=-1;
if((printf("%d",i))<(printf("%d",j)))
printf("%d",i);
else
printf("%d",j);
return 0;
}
As printf() returns the number of characters successfully printed, the condition will be if(1<1) which is false but the if part is executed and the output is 1 -1 1. Why this is happening?
I think it is rather obvious: ‘1’ is one character, ‘-1’ is two. One is less than two.