#include <stdio.h>
int main(void)
{
unsigned int a = 6;
int b = -20;
a + b > 6 ? puts("> 6") : puts("<= 6");
}
It is clear to me how the ternary operator work in this code.
I am not able to understand the addition of the signed
and unsigned
integer here.
When running this code, the output is > 6
; why?
a + b
betweenunsigned int a
andint b
. (Which frankly, I couldn't care less about, because my coding standards forbid performing arithmetic operations without previously converting everything to an explicit same type.) – Lovely