JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi sociology physics physical education maths english economics geography History

chemistry business studies biology accountancy political science

Class 12

Hindi physics physical education maths english economics

chemistry business studies biology accountancy Political science History sociology

Home science Geography

English medium Notes

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Class 12

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Categories: C Language in hindi

Preprocessor : Macro in hindi प्री प्रोसेसर में मैक्रो क्या है हिंदी c कंप्यूटर भाषा में macro in c language

प्री प्रोसेसर में मैक्रो क्या है हिंदी c कंप्यूटर भाषा में macro in c language , Preprocessor : Macro in hindi :-
इससे पहले के article मे , हमने file inclusion को पढ़ा |अब इस article मे हम macro को पड़ेगे जो की c language का महत्वपूर्ण tool है |
  1. Macro :
    Macro substitution एक येसी प्रोसेस होती जिसमे किसी प्रोग्राम के कोई keyword  को predefine value या expression (जो की दो  या दो से अधिक c टोकन से बनते है ) रेपल्स किया जाता है |Preprocessor का syntax होता है :

# define macro_name  value

इस syntax मे :
#define : ये macro Preprocessor को define करता है इसे macro definition  कहते है |
macro_nam : ये macro का नाम होता है जिसे value और expression के जगह प्रोग्राम मे use किया जाता है |
value /expression: ये  macro_name की value है या कोई expression होता है जिसका आउटपुट keyword की value होती है |

macro statement को main() function से पहले declare किया जाता है |अतः जब प्रोग्राम execute होता है तब सभी  macro_name की जगह  macro_name की value/expression की value replace हो जाती है |ये ध्यान रखन होते है की  macro_name और value के बीच space जरुर होना चाहिए | macro statement semicolon से terminate नहीं होता है |

C language मे अलग अलग प्रकार के macro होते है जिसमे तीन मुख्य होते है :-
1.Simple Macro
इस प्रकार मे  macro_name का replacement किसी constant value से होता है |जैसे
#define PI 22.7
#define COUNT 100
#define SIZE 450
#define CAPITAL “Jaipur”

उपर दिए गये उदाहरण मे , सभी macro statement मे macro_name कैपिटल मे लिखे गये है |किसी constant को capital letter मे लिखने से पहचना easy हो जाता है |

#define SIZE 12

इस उदहारण मे , प्रोग्रम मे जब जब SIZE लिखा जायेगा तब तब SIZE का रिप्लेसमेंट 12 से हो जायेगा |

उदहारण :
#include<stdio.h>
#include<conio.h>
#define PI 3.14
void main()
{
Printf(“Enter Radius”);
scanf(“%d”,&r);
printf(“Enter Height”);
scnaf(“%d”,&h);
Area = 2*PI*r*h;
Volume=PI*r*r*h;
printf(“Area=%f”,Area);
printf(“Volume=%f”,Volume);
getch();
}

Macro definition से , constant value के स्थान expression भी हो सकता है |इसका उदाहरण है :-
#define AREA   8*8
#define 2*PI      2*3.14
इन दोनों उदाहरन मे , AREA के स्थान 8*8=64 का replacement होगा और 2*PI के स्थान पर 6.28 replace होगा |
लेकिन जब किसी expression को macro definition मे use किया जाता है तभी उस expression को slove करने का कम्र पर ध्यान देना चाहिए क्योकि किसी expression का output expression के order पर निर्भर करता है |

किसी macro statement मे  expression को किसी भी expression से replace कर सकते है |जैसे
#define CONDITION if(a>b)
#define DISPLAY printf(“my name is “);
आदि |

C language मे c टोकन मे confuse हो सकते है |जैसे assignment operator और equal operator या and operator और address operator मे |इसलिए इस प्रॉब्लम को solve करने के लिए , हम सभी tokens को pre define कर देते है :
#define EQUAL              ==
#define ASSIGN              =
#define ADDRESS         &
#define AND                  &&
#define BACKLINE   printf(“\n”);
#define MOD                %

उदाहरण के लिए :
if(a MOD EQUAL 0)
{
printf(“perfect divid BACKLINE”);
printf(“Reminder is zero”);
}
else
{
printf(“Non Perfect divid BACKLINE”);
printf(“Reminder is non zero”);
}

2.Macro In function Argument

C language मे, function argument मे macro statement use कर सकते है |इसका syntax होता है :-

#define function_name(argument)    string

यहा पर :
function_name : ये उस function का नाम होता है जिसके आर्गुमेंट मे macro statement perform करना है |
argument: ये function का उस argument का नाम है जिसके जगह micro value assign होगी |
string : ये macro expression है जो function के argument मे replace होगा |

उदहारण के लिए:

#define  SQUARE(a)   a*a  // macro statement //

इस macro statement से ,SQUARE(a) के स्थान ओअर a*a replace हो जायेगा |जैसे :

Area of Square = SQUARE(a); // lets suppose a=10 //

तब इस statement से  Area of Square = a*a execute होगा  और Area of Square = 10*10 =100 होगी |

लेकिन जब area of square = SQUARE(x+y); perform होगा तब

इस statement से area of square = x+y * x+y * x+y ; execute होगा जो की error message देगा |इसलिए macro statement मे string के सभी members को () मे क्लोज किया जाता है |

#define  SQUARE(a)   ((a)*(a))  // macro statement //

इस statement के लिए ,area of square = ((x+y) * (x+y) * (x+y)) ; execute होगा जो की right आउटपुट देगा |

macro statement का function argument मे use काफी होता है |इसका comman उदहारण है :-
#define     MAXIMUM(x,y)                 ((x)>(y))?(x):(y))
#define     MINIMUM(x,y)                   ((x)<(y))?(x):(y))
#define     STRINGCMP(s1,s2)            (strcmp((s1),(s2))==0)
#define     STRINGCMP(s1,s2)            (strcmp((s1),(s2))>0)

3.Nesting of Macro
C language मे , किसी macro statement मे macro को use कर सकते है |इसलिए macro statement nested हो सकते है |
जैसे
#define A                  10
#define C                   34
#define B                  (A + 12 + C)

और
#define  PI                3.15
#define AREA(a)     2*PI*a;

Preprocessor जब तक nested macro statement को expand करेगा जब तब उस statement मे macro आते रहेगे |
जैसे उपर लिखे उदहारण -1 मे ,
B का replacement   (A + 12 + C) से होगा |
और बाद मे  (A + 12 + C)  मे , A और C का replacement 10और 34 से होगा |

और उदाहरण 2 मे ,
AREA (a) की जगह 2*PI *a replace होगे :
बाद मे  2*PI *a मे PI का replacement 3.14 से होगा |

2.Undefined Macro

जब यूजर किसी macro को प्रोग्रम के किसी specific part के लिए चाहता है तब इस Preprocessor का use किया जाता है |
इस Preprocessor मे macro statement को use करके उन्देफ़िएन कर सकते है |इसका syntax है :-

#undef macro_name;

यहा पर :
#undef  : ये  Preprocessor को declare करता है |
macro_name: ये उस macro का नाम होता है जिसे undefined करना है |

Sbistudy

Recent Posts

four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं

चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…

2 days ago

Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा

आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…

4 days ago

pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए

युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…

6 days ago

THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा

देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…

6 days ago

elastic collision of two particles in hindi definition formula दो कणों की अप्रत्यास्थ टक्कर क्या है

दो कणों की अप्रत्यास्थ टक्कर क्या है elastic collision of two particles in hindi definition…

6 days ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now