What if changing one word could fix your whole program instantly?
Why Define macro? - Purpose & Use Cases
Imagine you need to use the same constant value or a small piece of code many times in your program. You write it out again and again everywhere.
This manual way is slow and risky. If you want to change that value or code, you must find and update every place manually. It's easy to miss some spots and cause bugs.
Define macros let you give a name to a value or code snippet. Then you use that name everywhere. If you change the macro, all uses update automatically when you compile.
#define PI 3.14 float area = 3.14 * r * r;
#define PI 3.14
float area = PI * r * r;Macros make your code easier to read, maintain, and update by replacing repeated values or code with simple names.
Think of a recipe where you use the same spice amount many times. Instead of writing '1 teaspoon' each time, you write 'SPICE_AMOUNT' once. Change it once, and the whole recipe updates.
Macros save time by avoiding repeated typing.
They reduce errors by centralizing values or code.
They make programs easier to update and understand.