Why do i get negative number when executing this?
unsigned int a = 1 << 31;
The problem isn't the fact that you're bit shifting. You are simply not printing in the corresponding format.
%d or %i is for printing int, and thus when you try to print your unsigned int, it is converted into an signed int.