Nested Macros: Presented By: Ishita Sharma Student Of: Trinity Institute of Professional Studies
Nested Macros: Presented By: Ishita Sharma Student Of: Trinity Institute of Professional Studies
Macros
P R E S E N T E D B Y: I S H I TA S H A R M A
S T U D E N T O F: T R I N I T Y I N S T I T U T E O F P R O F E S S I O N A L S T U D I E S
Introduction to
Macros
Exampl
A macro is essentially a
e -
#include <stdio.h>
piece of code or a value that
// Define a macro for the value of pi
is associated with an #define PI 3.14
identifier. It is defined using int main() {
double radius = 5.0;
the #define preprocessor double area = PI * radius * radius;
printf("The area of the circle is: %lf\
directive. n", area);
return 0;
}
OUTPUT: The area of the circle is: 78.50
Types of Macros
• Object-like macros replace code with meaningful
Object like macro names, improving readability. They simplify
maintenance by allowing changes in one place,
reducing repetition and errors
• Function-like macros act like functions, taking
inputs to perform tasks and enable code reuse.
Function-Like Macros They simplify development, reduce repetition, and
improve coding efficiency and productivity..