📘 Lesson  ·  Lesson 60

Macros & Preprocessor

Macros & Preprocessor

What is the Preprocessor?

💡 Note

The preprocessor runs before compilation. Directives start with # — like #include and #define.

Macros

C
#include <stdio.h>
#define PI 3.14
#define SQUARE(x) ((x)*(x))

int main() {
    printf("%.2f\n", PI);       // 3.14
    printf("%d\n", SQUARE(5));  // 25
    return 0;
}
Output:
3.14 25

Summary

  • #define creates constants and macro functions; #include adds files.
  • Macros are replaced by the preprocessor before compiling.

Preprocessor क्या है?

💡 Note

Preprocessor compilation से पहले चलता है। Directives # से शुरू होती हैं — जैसे #include और #define

Macros

C
#include <stdio.h>
#define PI 3.14
#define SQUARE(x) ((x)*(x))

int main() {
    printf("%.2f\n", PI);       // 3.14
    printf("%d\n", SQUARE(5));  // 25
    return 0;
}
Output:
3.14 25

सारांश

  • #define constants और macro functions बनाता है; #include files जोड़ता है।
  • Macros compile से पहले preprocessor द्वारा replace होते हैं।
← Back to C Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

\n