1.3Top-Down Design
Covers IGNOU MCS-201 §1.3.4
Large problems are too big to hold in your head at once. Top-down design is a disciplined way to break them into pieces small enough to solve one at a time. It is also the reason C programs are built out of functions.
The idea
Top-down design is also called stepwise refinement, because each pass refines the previous one with more detail. While refining, you must also define how the sub-tasks pass data to each other, so the overall structure stays correct.
A reliable first level: Input → Process → Output
When you are unsure how to split a problem, start with three questions:
- Input: where does the data come from?
- Process: what must be calculated?
- Output: what must be shown or saved?
Then break each of these down again.
- Student details
- Marks per subject
- Total
- Percentage
- Grade, pass/fail
- Header
- Marks table
- Result line
Top-down versus bottom-up
| Aspect | Top-down | Bottom-up |
|---|---|---|
| Starting point | The whole problem | Small, reusable components |
| Direction | Break down | Build up |
| Typical use | Planning procedural programs, such as C | Libraries, object-oriented design |
| Advantage | The overall structure is clear from the start | Components are well tested and reusable |
| Risk | Pieces may be hard to reuse elsewhere | Pieces may not fit the final goal |
In practice, programmers combine both: they plan top-down and build some reusable parts bottom-up.
Key takeaways
- Top-down design starts with the whole problem and refines it step by step.
- Input → Process → Output is a dependable first level.
- Each lowest-level task usually becomes one function in C.
- Bottom-up design builds from small components; real projects often use both.
Practice questions
Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 6 · short answer
Use top-down design to break “calculate and print an electricity bill” into two levels.
Show worked answer
Level 1 follows Input → Process → Output. 1. Read data: 1.1 read customer name and meter number; 1.2 read previous and current meter readings. 2. Calculate bill: 2.1 units ← current reading − previous reading; 2.2 energy charge ← units × rate per unit; 2.3 total ← energy charge + fixed charge. 3. Print bill: 3.1 print customer details; 3.2 print readings and units used; 3.3 print charges and total amount. Each level-2 task is small enough to become one function.