The code segment `struct ex { int i1:2; int i2:3; };` declares a structure named `ex` with two integer fields `i1` and `i2` with specified bit sizes of 2 and 3 respectively. The bit size determines the range of possible integer values that the field can hold.
For `i1` with a bit size of 2, it can hold the following integer values:
- -2: Binary representation: `10`
- -1: Binary representation: `11`
- 0: Binary representation: `00`
- 1: Binary representation: `01`
So, the range of possible integer values for `i1` is -2 to 1.
For `i2` with a bit size of 3, it can hold the following integer values:
- -4: Binary representation: `100`
- -3: Binary representation: `101`
- -2: Binary representation: `110`
- -1: Binary representation: `111`
- 0: Binary representation: `000`
- 1: Binary representation: `001`
- 2: Binary representation: `010`
- 3: Binary representation: `011`
So, the range of possible integer values for `i2` is -4 to 3.