#include<stdio.h>
int main(void)
{
signed int a=-1;
unsigned int b=1;
int c= a+b;
printf("%d\n",c);
return 0;
}
According to the rule of Implicit type conversion, if one operand is unsigned int
,the other will be converted to unsigned int
and the result will be unsigned int
in a binary operation.
so here as b
is unsigned int
, a
should be type casted to unsigned int
.As unsigned int is always +ve , so the value of a
will be 1.so c=1+1=2
.But the output is 0
.How ?