// math.c - Demonstrates various symbol types and linkage #include // Global symbols - exported (visible to other files) int pi = 3; int e = 2; // Static global - local to this file only static int randomval = 7; // External declarations - symbols defined elsewhere extern int usrid; // Function definitions // Global function - exported symbol int square(int x) { return x * x; } // Static function - local to this file only static int is_prime(int x) { if (x < 2) return 0; if (x == 2) return 1; if (x % 2 == 0) return 0; for (int i = 3; i * i <= x; i += 2) { if (x % i == 0) return 0; } return 1; } // Global function that uses static function int pick_prime() { int candidate = randomval; while (!is_prime(candidate)) { candidate++; } return candidate; } // Function that references external symbol int get_n() { return usrid; } // Function that demonstrates various symbol types void show_values() { printf("Global symbols: pi=%d, e=%d\n", pi, e); printf("Static symbol used internally: randomval=%d\n", randomval); printf("External symbol: usrid=%d\n", usrid); printf("Function results: square(5)=%d, pick_prime()=%d\n", square(5), pick_prime()); }