---
title: "Making programs more readable"
subject: "Instrumentation II"
chapter: 9
key: "semester_5/instrumentation_ii:readable-programs"
source: https://www.bctengineer.com/q/semester_5/instrumentation_ii/readable-programs
site: BCT Engineering
---

# Making programs more readable

Instrumentation II · Chapter 9: Software For Instrumentation And Control Applications

- Asked in: 2072 Kartik, 8 marks
- Answer checked by Claude Sonnet 5.5 on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/instrumentation_ii/readable-programs
- Whole chapter: https://www.bctengineer.com/md/semester_5/instrumentation_ii/chapter-9

## Question

Programs are to be read by humans. For programs to be useful, reliable and maintainable, you must make them readable and understandable. Good design and programming practices can make programs more readable. Explain in brief how you can make programs more readable.

## Short answer

Make programs readable by using meaningful names, helpful comments, consistent layout, modular structure, and simple expressions. Avoid global variables and magic numbers; follow coding standards and peer reviews.

## Answer

Programs are read more often than they are written, so readability makes maintenance and debugging easier. A program can be made more readable by:

1. **Meaningful names:** use descriptive names (`motor_speed`, not `x`) for variables, functions and constants; follow one naming convention.
2. **Comments:** a header block at the start of each module and function (purpose, inputs, outputs, author, date, revision), plus brief comments for complex logic, explaining why. Avoid obvious comments and keep comments updated.
3. **Consistent layout:** proper indentation, one statement per line, blank lines between logical blocks, limited line length, uniform brace style.
4. **Modular structure:** small functions with one task and few parameters; top-down design and clear interfaces; limit nesting depth.
5. **Structured control flow:** use if/else, for, while and switch; avoid goto and tricky constructs.
6. **Named constants:** replace magic numbers with `#define` or `const`; define hardware addresses in one header file.
7. **Avoid global variables** and side effects; declare variables near their use.
8. **Simple expressions:** break complex expressions with parentheses and temporary variables; prefer clarity to cleverness.
9. **Documentation** such as flowcharts, a design document and version history; use version control.
10. **Coding standards and peer reviews** to maintain uniformity.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which name is better for readability?
   A. x
   B. a1
   C. motor_speed
   D. tmp
   Answer: C. Descriptive names make code understandable. (Key point: Meaningful names)

2. How should magic numbers be handled?
   A. Leave them inline
   B. Use random values
   C. Comment them only
   D. Replace with named constants using #define or const
   Answer: D. Named constants improve readability. (Key point: Magic numbers)

3. What should comments avoid?
   A. Obvious comments, and they should be kept updated
   B. Headers
   C. Explaining why
   D. Describing inputs and outputs
   Answer: A. Avoid obvious comments; explain why. (Key point: Comments)

4. How should functions be?
   A. Long with many tasks
   B. Small, with one task and few parameters
   C. Heavily nested
   D. Using many globals
   Answer: B. Small focused functions are easier to read. (Key point: Modular structure)

## Related in Instrumentation II

- [Good programming practice and software selection](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Agood-programming-software-selection) — Instrumentation II, chapter 9, asked 2×

## Related in other subjects

- [T/F: radial more reliable than network](https://www.bctengineer.com/question.md?key=semester_8%2Ftransmission_and_distribution_system_design%3Atf-radial-more-reliable-network) — Transmission and Distribution System Design, chapter 5, asked 2×
- [Physiological effects of shock and safety practices](https://www.bctengineer.com/question.md?key=semester_8%2Fhigh_voltage_engineering%3Ashock-effects-safety-practices) — High Voltage Engineering, chapter 2, asked 2×
- [Read records until end; show nth record](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afile-worker-nth-record) — Computer Programming, chapter 10, asked 2×
- [Orientation in plane tabling; reliable method](https://www.bctengineer.com/question.md?key=semester_3%2Fsurveying_i%3Aorientation-more-reliable-method) — Surveying I, chapter 6, asked 2×
