---
title: "Basic concepts of modular programming"
subject: "Software Engineering"
chapter: 3
key: "semester_5/software_engineering:modular-programming"
source: https://www.bctengineer.com/q/semester_5/software_engineering/modular-programming
site: BCT Engineering
---

# Basic concepts of modular programming

Software Engineering · Chapter 3: Architectural design

- Asked in: year not given, 5 marks
- Video: [MODULARITY-SOFTWARE ENGINEERING-IIIBSC-PAPER-V(B)](https://www.youtube.com/watch?v=DZgtNeW43q0) — MVN JS & RVR College of Arts and Science
- Answer checked by Claude Sonnet 5.5 on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/software_engineering/modular-programming
- Whole chapter: https://www.bctengineer.com/md/semester_5/software_engineering/chapter-3

## Question

What are basic concept of modular programming? Explain with example.

## Short answer

Modular programming splits a program into named modules with clear interfaces, information hiding, high cohesion and low coupling, enabling independent development, testing and reuse. Example: a student result program has main() calling readMarks(), calcPercent(), getGrade() and printReport(); changing grading rules requires changing only getGrade().

## Answer

**Modular programming** is a design and programming technique in which a large program is divided into small, separate, named units called **modules**, each performing one well-defined task and interacting with other modules only through clear interfaces.

#### Basic concepts
1. **Module** – a self-contained unit (function, procedure, file, package or class) with a name, inputs, outputs and a single purpose.
2. **Decomposition** – the problem is split into sub-problems, usually top-down, until each piece is small enough to code easily.
3. **Interface** – each module exposes only what others need (function names, parameters, return values); callers depend on the interface, not the code.
4. **Information hiding** – internal data and algorithms are hidden inside the module (Parnas), so they can change without affecting other modules.
5. **High cohesion** – all statements in a module work toward one task.
6. **Low coupling** – modules depend on each other as little as possible, ideally passing only the data they need.
7. **Independent development and compilation** – modules can be written, compiled and unit-tested separately, by different programmers.
8. **Reusability** – a general module (e.g. date validation) can be reused in many programs.

#### Example: student result processing in C

```text
                     +-------------+
                     |   main()    |
                     +-------------+
        +-----------+-----+-------+------------+
        |                 |       |            |
+-------------+ +---------------+ +-----------+ +---------------+
| readMarks() | | calcPercent() | | getGrade()| | printReport() |
+-------------+ +---------------+ +-----------+ +---------------+
```

```c
void readMarks(int m[], int n);          /* input module   */
float calcPercent(int m[], int n);       /* compute module */
char getGrade(float pct);                /* grading rule   */
void printReport(float pct, char g);     /* output module  */

int main(void) {
    int marks[5];
    readMarks(marks, 5);
    float p = calcPercent(marks, 5);
    printReport(p, getGrade(p));
    return 0;
}
```

If the university changes its grading rules, only `getGrade()` is changed; the other modules are untouched.

#### Advantages
- Easier to understand, code and debug.
- Parallel development by a team.
- Easier testing (unit testing per module) and maintenance.
- Reuse of modules in other programs.

## Check yourself

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

1. What does information hiding achieve in modular programming?
   A. Internals can change without affecting other modules
   B. Every module can access all global data
   C. Modules cannot be tested separately
   D. Interfaces become unnecessary
   Answer: A. Internal data and algorithms are hidden (Parnas), so changing them does not affect other modules. (Key point: Information hiding)

2. What should callers of a module depend on?
   A. Its internal algorithm
   B. Its source code layout
   C. Its interface (names, parameters, return values)
   D. Its global variables
   Answer: C. Callers depend on the interface, not the code inside the module. (Key point: Interface)

3. Which combination is the goal of a good modular design?
   A. Low cohesion, low coupling
   B. High cohesion, high coupling
   C. Low cohesion, high coupling
   D. High cohesion, low coupling
   Answer: D. All statements of a module should serve one task (high cohesion) and modules should depend on each other as little as possible (low coupling). (Key point: Cohesion and coupling goal)

4. In the student result example, the university changes its grading rules. Which module changes?
   A. Only getGrade()
   B. main() and readMarks()
   C. All modules
   D. printReport() and calcPercent()
   Answer: A. The grading rule is isolated in getGrade(), so the other modules are untouched. (Key point: Benefit shown by example)

## Related in other subjects

- [Basic requirements of linear programming](https://www.bctengineer.com/question.md?key=semester_7%2Fproject_engineering%3Alinear-programming-requirements) — Project Engineering, chapter 3
- [Cloud and grid computing concepts](https://www.bctengineer.com/question.md?key=semester_8%2Finternet_and_intranet%3Acloud-grid-computing) — Internet and Intranet, chapter 7, asked 2×
- [Simple program illustrating OOP concept](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Aoop-simple-program) — Object Oriented Programming, chapter 1
- [Concept of class with example](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Aclass-concept-example) — Object Oriented Programming, chapter 1
