IPv4 addresses and subnet sizes: Class 12 practice
An IPv4 address has 32 bits. The quick answer and an example come first; then the method, worked examples and six graded questions.
IPv4 addresses and subnet sizes: quick answer
An IPv4 address has 32 bits. With a /n prefix, 32 − n bits identify hosts, giving 2^(32−n) addresses of which 2^(32−n) − 2 are usable hosts (network and broadcast are reserved).
Example: How many usable host addresses does a /26 network have? Answer: 62.
- Where it is taught: "Computer Networks", Class 12 Computer Science.
- On this page: the method, 3 worked examples and 6 graded questions with a full answer key.
How to use this page (about 30 minutes)
- Read the method once, then cover the worked examples and try them yourself before reading the steps.
- Do the two Basic questions without notes. If either is wrong, re-read the matching worked example.
- Do the Standard and Challenge questions, then check every line of working against the answer key — not only the final answer.
- Write down the mistake behind each wrong answer and redo that question the next day.
What you should know first
- Powers of 2
The idea behind ipv4 addresses and subnet sizes
An IPv4 address has 32 bits. With a /n prefix, 32 − n bits identify hosts, giving 2^(32−n) addresses of which 2^(32−n) − 2 are usable hosts (network and broadcast are reserved).
Step-by-step method
- Host bits = 32 − prefix.
- Addresses = 2^(host bits).
- Usable = addresses − 2.
Worked example 1 (Basic)
How many usable host addresses does a /26 network have?
- Host bits = 6
- 2^6 − 2 = 62
- Answer: 62
Worked example 2 (Standard)
How many usable host addresses does a /20 network have?
- Host bits = 12
- 2^12 − 2 = 4094
- Answer: 4094
Worked example 3 (Challenge)
What is the longest prefix that still gives at least 67 usable hosts?
- Need 2^h − 2 ≥ 67 → h = 7
- Prefix = 32 − 7 = /25
- Answer: /25
Common mistakes and misconceptions
- Forgetting to subtract 2
- Using the prefix as host bits
Practice questions
- (Basic) How many usable host addresses does a /27 network have?
- (Basic) How many usable host addresses does a /30 network have?
- (Standard) How many usable host addresses does a /24 network have?
- (Standard) How many usable host addresses does a /21 network have?
- (Challenge) What is the longest prefix that still gives at least 572 usable hosts?
- (Challenge) What is the longest prefix that still gives at least 840 usable hosts?
Answer key with full working
- Q1: Host bits = 5 → 2^5 − 2 = 30 → Answer: 30
- Q2: Host bits = 2 → 2^2 − 2 = 2 → Answer: 2
- Q3: Host bits = 8 → 2^8 − 2 = 254 → Answer: 254
- Q4: Host bits = 11 → 2^11 − 2 = 2046 → Answer: 2046
- Q5: Need 2^h − 2 ≥ 572 → h = 10 → Prefix = 32 − 10 = /22 → Answer: /22
- Q6: Need 2^h − 2 ≥ 840 → h = 10 → Prefix = 32 − 10 = /22 → Answer: /22
Which textbook this practice follows
This skill is taught under "Computer Networks" in Class 12 Computer Science. Check your own textbook's contents page — CBSE, ICSE/ISC and state boards order chapters differently.
Answers on this page are generated and automatically re-checked by a second, independent calculation. They have not been reviewed by a teacher — if you spot a problem, tell us on WhatsApp.
Still stuck after the answer key?
If the same step in ipv4 addresses and subnet sizes keeps going wrong, a short live 1 on 1 class can find the exact gap. The first demo class is free; send the class, board and chapter on WhatsApp (+91 9379416374).
Related practice and notes
More Class 12 Computer Science practice
Continue with this syllabus
Frequently asked questions
Which chapter is ipv4 addresses and subnet sizes in?
This skill is taught under "Computer Networks" in Class 12 Computer Science. Check your own textbook's contents page — CBSE, ICSE/ISC and state boards order chapters differently.
Which question should I start with?
Start with the Basic questions. Move to Standard only when both Basic answers match the key with the same working; the Challenge questions combine this skill with earlier ones.
How were the answers checked?
Answers on this page are generated and automatically re-checked by a second, independent calculation. They have not been reviewed by a teacher — if you spot a problem, tell us on WhatsApp.
Is this only for CBSE?
The skill names follow NCERT/CBSE, but the method is the same for ICSE, state boards, IGCSE and IB. Only the chapter name and order differ.
Can I get live help with this topic?
Yes. RG's E-Learning teaches live 1 on 1 online classes; the first demo class is free and fees are shared after it.