0% found this document useful (0 votes)
7 views11 pages

Understanding Pre-Processor Directives

The document discusses pre-processor directives in C programming, covering topics such as file inclusion, modularity, debugging, and macro definitions. It provides examples of code demonstrating these concepts, including the use of the 'printf' function and conditional compilation with debugging. Overall, it serves as a guide for understanding how pre-processor directives enhance code organization and functionality.

Uploaded by

manicyam1234
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views11 pages

Understanding Pre-Processor Directives

The document discusses pre-processor directives in C programming, covering topics such as file inclusion, modularity, debugging, and macro definitions. It provides examples of code demonstrating these concepts, including the use of the 'printf' function and conditional compilation with debugging. Overall, it serves as a guide for understanding how pre-processor directives enhance code organization and functionality.

Uploaded by

manicyam1234
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

FLIP CLASS

T O P I C : T H E P R E - P R O C E SS E R D I R E C T I V E
2
#include <stdio.h>

#define PI 3.14

int main() {

printf("The value of PI is %.2f\n",


PI);

return 0;

} YOUR CODE

3
LINKERS EXAMPLE

Main.c

#include <stdio.h>
Math.c
int add(int, int);
int add(int a, int b) {
int main()

{
return a + b;

int result = add(3, 4); }


printf("The sum is: %d\n", result);

return 0;

4
PRE-PROCESSOR DIRECTIVE
• FILE INCLUSION

• MODULARITY

• DEBUGGING
AND CONDITIONAL CODING

• MACRO DEFINATION

CONTENT

6
FILE INCLUSION

#include <stdio.h> // Content of stdio.h is copied here during


preprocessing
int main() {
#define printf(...) ...
printf("Hello World\n");
int main() {
return 0;
printf("Hello World\n");
}
return 0;

7
#include <stdio.h>

#define DEBUG

int main() {

printf("Program started.\n");

#ifdef DEBUG

printf("Debug mode enabled.\n");

#endif

printf("Program running...\n");
DEBBUGING
return 0;

8
MODULARITY

// file: main.c // file: math_operations.h

#include <stdio.h> #ifndef MATH_OPERATIONS_H

#include "math_operations.h" #define MATH_OPERATIONS_H

int main() { Int add(int a, int b)

int result = add(5, 3); { return a + b; }

printf("The result is: %d\n", result); Int subtract(int a, int b) {

return 0; return a - b;

} } #endif

9
MACROS
#define PI 3.14

printf("Area of circle: %f\n", PI * r * r);

10
THANK YOU

You might also like