Please have a look at this code:
#include <stdio.h>
int main(void)
{
short s = -1;
printf("sizeof(short) = %lu\n", sizeof(short));
printf("sizeof(int) = %lu\n", sizeof(int));
printf("sizeof(long) = %lu\n", sizeof(long));
printf("s = %hd\n", s);
printf("s = %d\n", s);
printf("s = %ld\n", s);
return 0;
}
It gave output as :
sizeof(short) = 2
sizeof(int) = 4
sizeof(long) = 8
s = -1
s = -1
s = 4294967295
In last line why s = 4294967295
instead of s = -1
as through this question I came to know that In C when variable gets promoted, its value remains constant.