main.c - Using our math_utils.h
#include <stdio.h>
#include "math_utils.h"
int main() {
int x = 10, y = 5;
printf("%d + %d = %d\n", x, y, add(x, y));
printf("%d - %d = %d\n", x, y, subtract(x, y));
double radius = 3.0;
printf("Area of circle with radius %.1f = %.2f\n",
radius, calculate_circle_area(radius));
printf("Value of PI: %f\n", PI);
return 0;
}
Compilation
# Compile all source files together
gcc main.c math_utils.c -o program
# Run the program
./program
Best Practices:
• Keep header files in the same directory as your source files
• Use descriptive names for header guards (e.g., MATH_UTILS_H)
• Document your header files with comments
• Group related functions in the same header file