#include <stdio.h>
void main()
{
int var= ~7;
printf("%d\n",var);
}
if you write a code like this, then the output will be -8.Reason is simple
7 in binary is 0111
not of 7=(~7) in binary is 1000 = 8 and note that the MSB is 1,hence the value will be considered as negative.Hence ~7= -8.
In other words ,we can easily remember it as : NOT OF A NUM= -(NUM+1)