when i run below code in codechef ide it prints: a = 0, b = 0, c = 1, d = 0 (note: b=0)
#include <stdio.h>
int main()
{
int a = 1;
int b = 1;
int c = a || --b;
int d = a-- && --b;
printf(“a = %d, b = %d, c = %d, d = %d”, a, b, c, d);
return 0;
}
but when i write same code differently like this it prints : b = -1, c = 0, d = -1
#include <stdio.h>
int main()
{
int b = 1;
int c = - -b; //predecrement gave more space between - as it was showing a single -
int d = - -b;// predecrement
printf(“b = %d, c = %d, d = %d”, b, c, d);
return 0;
}
why is b not equal to -1 in first as in both prgrm its predecrement