Question:medium

If an IP network uses a subnet mask of \(255.255.240.0\), the maximum number of IP addresses that can be assigned to network interfaces is ______.

Show Hint

Count the number of 1 bits in the subnet mask to get the network bits, then use 2 raised to the number of host bits, minus 2 for the network and broadcast addresses.
Updated On: Jul 22, 2026
Show Solution

Correct Answer: 4094

Solution and Explanation

Step 1: Read the mask as a CIDR prefix.
Instead of converting each octet separately, notice that a mask of $255.255.240.0$ is a common CIDR value. The third octet $240$ in binary is $11110000$, which has 4 leading ones. So the mask has $8+8+4=20$ leading one bits, written as $/20$.

Step 2: Use the general host-count formula.
For a network with prefix length $n$ out of 32 bits, the number of addresses that can be handed out to interfaces is
$$ 2^{32-n} - 2 $$
The subtraction of 2 accounts for the network id and the broadcast address, which are reserved and never given to a device.

Step 3: Plug in the prefix length.
Here $n=20$, so
$$ 2^{32-20} - 2 = 2^{12} - 2 $$

Step 4: Work out the power of two.
$2^{12} = 4096$, since $2^{10}=1024$ and $2^{12}=1024 \times 4 = 4096$.

Step 5: Double check by counting the addresses directly.
A $/20$ block sits inside the third octet, since 20 bits covers the first two full octets ($8+8=16$ bits) plus 4 more bits into the third octet. That leaves $4$ bits of the third octet plus the whole fourth octet as host bits, which is $4+8=12$ host bits, matching Step 3. Each block of this size spans $16$ values in the third octet, since $2^4=16$, and all $256$ values in the fourth octet, giving $16\times256=4096$ addresses in the block, the same total found above.

Step 6: Subtract the reserved addresses.
Out of these 4096 addresses, one is the all zero host address that names the network itself, and one is the all one host address used for broadcasting to every device on that network. Both are set aside and are never handed to an actual interface:
$$ 4096 - 2 = 4094 $$

Step 7: Conclude.
$$ \boxed{4094} $$
Was this answer helpful?
0


Questions Asked in GATE CS exam