[Solved] printing the ranges of fundamental datatypes in c


You have several problems:

Use d for signed integers.

Use u for unsigned integers.

char and short are promoted to int. Don’t add ll or l to them.

Add l with long types, not ll.

Edit:

To clarify:

int == %d
unsigned int == %u
long == %ld
unsigned long == %lu

Also you cannot represent range of signed integer with the same data type, you need to use bigger type. INT_MAX-INT_MIN won’t work. It needs to be (long)INT_MAX-(long)INT_MIN and you need to use %ld to display it. And even that won’t work if sizeof int == sizeof long.

6

solved printing the ranges of fundamental datatypes in c