#include <stdio.h>
int main() {
unsigned char a = 5;
printf("%d\n",~a);
printf("%d\n",a=~a);
return 0;
}
According to the accepted answer here Negation inside printf , in the first printf, a
should get promoted to an int
and the output should be a large negative number. But the output of the first printf is -6. Can you please explain why the output is -6 and why the char is not promoted to int in this case?