<aside> đź’ˇ Modularization in C refers to the process of dividing a large program into smaller, more manageable parts called modules. Each module is a self-contained unit of code that performs a specific function or task.

</aside>

A module provides a collection of functions that share a common aspect or purpose.

Screen Shot 2023-03-06 at 11.18.14 AM.png

There exists 3 key advantages:

Declaration

In C, a function or variable must be declared before it can be accessed

A declaration introduces an identifier into a program and specifies a type

Declaration vs. Definition

Variable declaration

// this program demonstrates VARIABLE declarations

#include <stdio.h>
#include "cs136-trace.h"

extern int g;              // variable DECLARATION

int main(void) {
  printf("%d\\n", g);       // this is now ok
  trace_int(g);
}

int g = 7;

(Note that it uses the “extern” keyword)