Yeah very good question and thanks for asking ...
In the above example, I am assuming the size of the integer is a 4 bytes (32 bit). Let us assume that the compiler represents signed negative integers number in 2’s complement notation. when casting the negative integer number than no bits will be changed the only compiler treat the stored bits as the unsigned integer.
Question
Now -10 will be stored as 2's complement form and after unsigned the value of the variable stored in 2's complement does not changed only type is changed.
if i take only 8 bit to represent -10 then
2's complement of -10:= 11110110
Now after unsigned it is (11110110) in decimal 246.
x=246
X=20
if(X>x) is now false then else block will be executed .
Because u have use
printf("%d" ,x) which is used to get integer values . so if u replace it with %ud then u will get the point .
#include <stdio.h>
int main(void)
{
int i = -6;
unsigned int ui = (unsigned int)i;
printf("%d %ud\n",ui,ui);
return 0;
}