The unsigned short int type can be used for variables which will have only positive and zero whole number values, within the range of the unsigned short type.
| 1 | 1 | 1 | 1 | 1 | 1 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5 | 4 | 3 | 2 | 1 | 0 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Nattural Binary Magnitude | |||||||||||||||
#include <stdio.h>
#include <limits.h>
int main () {
short unsigned c; /* int by default */
short unsigned int d; /* Explicit */
short int unsigned e; /* Explicit */
unsigned short i; /* int by default */
unsigned short int j; /* Explicit */
unsigned int short k; /* Explicit */
int unsigned short y; /* Explicit */
int short unsigned z; /* Explicit */
c = 3;
d = 4;
e = 5;
i = 6;
j = 7;
k = 8;
y = 10;
z = 11;
printf ("c is %u (%d bytes)\n", c, sizeof c);
printf ("d is %u (%d bytes)\n", d, sizeof d);
printf ("e is %u (%d bytes)\n", e, sizeof e);
printf ("i is %u (%d bytes)\n", i, sizeof i);
printf ("j is %u (%d bytes)\n", j, sizeof j);
printf ("k is %u (%d bytes)\n", k, sizeof k);
printf ("y is %u (%d bytes)\n", y, sizeof y);
printf ("z is %u (%d bytes)\n", z, sizeof z);
printf ("The range of the unsigned short int type is from %u to %u\n",
0, USHRT_MAX);
return 0;
}