JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: C Language in hindi

Preprocessor : File Inclusion in hindi in c language प्रीप्रोसेसर : फाइल इन्क्लुसन क्या है c कंप्यूटर भाषा में हिंदी में

प्रीप्रोसेसर : फाइल इन्क्लुसन क्या है c कंप्यूटर भाषा में हिंदी में Preprocessor : File Inclusion in hindi in c language :-
C language unique language है | इसमे structure और pointer है जो की powerful tool है |इसके अलावा preprocessor एक unique feature है |जो की किसी दूसरी high level language मे नहीं होता है |इस tool से प्रोग्रामर किसी प्रोग्राम को readable , modify और efficient बना सकता है |Preprocessor
जैसे की नाम से पता चलता है की इस keyword को कोम्प्लिएर मे सेंड करने से पहले define किया जाता है |preprocessor को main() function से पहले declare किया जाता है |
अगर preprocessor किसी प्रोग्राम मे declare किया गया है तब source code कोम्प्लिएर मे pass होता है तब कोम्प्लिएर सबसे पहले check preprocessor  की उपस्थिति को check करता है |
preprocessor  का syntax normal clanguage syntax से अलग -अलग होता है |ये ‘#” से start होता है और ‘;’ से terminate होता है |इसके अलावा #include और #define extention को use कर सकते है |
preprocessor  की लिस्ट है :-

1. #define
ये किसी macro को define करने के लिए use होता है |
2.#undef
ये किसी macro को undefine करने के लिए use होता है |
3.#include
किसी file को include करने के लिए किया जाता है |
4.#ifdef
ये किसी macro definition को test करता है |
5.#endif
ये किसी if statement को end को specify करता है |
6.#ifndef
ये test करता है macro को define किया है नहीं |
7.if
ये complie time condition को test करता है |
8.else
ये किसी alternative को define करता है अगर if statement fail हो जाये |

Preprocessor  को तीन प्रकार है :-
1.File Inclusion directives
2.Macro substitution directives
3.Complier control directive

File Inclusion
जब कोई external file किसी  function और macro को contain करता है |उस external file को किसी file मे add करने करने के लिए File Inclusion satement का use कर सकते है |इसका syntax है :-


#include “file name “;


यहाँ पर :
#include: ये perprocessor का keyword है |जिसका मतलब है file name को इस प्रोग्राम को add करता है |
file name : उस file का नाम है जिसमे macro और दुसरे function को contain करता है |

जब ये statement execute होता है  perprocessor “file name” के सभी content ,प्रोग्राम के source code मे add  हो जाते है |
perprocessor file name को सबसे पहले current directive मे search होती है और बाद मे standard directive मे search होती है |
इसका दूसरा syntax भी है :-

#include<file name >

इस सुन्ताक्स से, perprocessor file name को standard directive मे search होता है |

उदाहरण के  लिए:
चलो support करते है की header.h एक एसी file मे जिसमे की दो function add() और sub() or list ऑफ़ header.file और macro के syntax है |
अब इस file को किसी भी प्रोग्राम मे add कर सकते है जैसे calculator ,averge और many more मे add कर सकते है |

//header.h//
#include<conio.h>
#includ<,stdio.h>
void add();
void sub();
void area();
#define pi 22.7

Main function:
#include “header.h”    // file inclusion //
void main()
{
add();
sub();
area();
getch();
}
void add()
{
int a,b,sum;
printf(“Data”);
scanf(“%d %d”,&a,&b);
sum=a+b;
printf(“Output sum =%d”,sum);
}
void sub()
{
int a,b,sub;
printf(“Data”);
scanf(“%d %d”,&a,&b);
sub=a-b;
printf(“Output sum =%d”,sub);
}
void area()
{
int r;
float area;
printf(“Enter radius”);
scanf(“%d”,&r);
area=pi*r*r;
printf(“Area=%f”,area);
}

इस उदाहरण मे , main function के start मे #include”header.h” से file header.h को add किया गया है जिससे की सभी user define function add() और sub() और area() के declartion ,macro pi 22.7 define किया  गया है जिसे main function और यूजर define function मे use किया गया है |

आउटपुट होगा :
Data 23 54
Output Sum  77

Data 23 12
Output Difference 11

Enter Radius 12
Area 3268.8

Nesting of File Inclusion:
C language मे File Inclusion का nesting possible है |इसका मतलब है दो या दो से अधिक file को किसी प्रोग्राम मे add करा सकते है |अगर include file नहीं मिलता तब error occur होती है और प्रोग्राम terminate हो जाता है |
उदाहरण के लिए
किसी header file बनाने के लिए यूजर को सबसे पहले header file को देक्लार करना पड़ता है |जैसे
// file name : mathmatic.h//
int add (int c, int b )
{
int sum ;
sum=c+d;
return (sum);
}
int sub (int c, int b )
{
int sub ;
sub=c-d;
return (sub);
}
int mul (int c, int b )
{
int mul ;
mul=c+d;
return (mul);
}
//close file statement //

Main Function 1:
#include<stdio.h>
#include<conio.h>
#include “mathmatic.h”
void main()
{
printf a,b,output
printf(“Data”);
scanf(“%d %d”,&a &b);
output=add(a,b)+sub(a,b)
printf(“Output=%d”,output);
getch();
}

Main Function -2
#include<stdio.h>
#include<conio.h>
#include “mathmatic.h”
void main()
{
int num,i;
printf(“enter a number\n “);
scanf(“%d”,&num);
printf(“table  of %d \n”,num);
for(i=1;i<=10;i++)
{
printf(“%d”,mul(num,i));
}
getch();
}

इस उदाहरन मे ,mathmatic.h को दो अलग अलग प्रोग्राम मे use किया गया है |
पहले प्रोग्राम मे , add() और sub() को use किया है |
दुसरे function प्रोग्राम मे, table को print करने के लिए mul() फ़ुइन्क्तिओन को use किया गया है |

आउटपुट (उदहारण 1) होगा :
Data 23 12
Output 46

आउटपुट ( उदाहरण 2 ) होगा :

enter a number 2
table  of 2
2 4 6 810121416 18 20

Sbistudy

Recent Posts

मालकाना का युद्ध malkhana ka yudh kab hua tha in hindi

malkhana ka yudh kab hua tha in hindi मालकाना का युद्ध ? मालकाना के युद्ध…

4 days ago

कान्हड़देव तथा अलाउद्दीन खिलजी के संबंधों पर प्रकाश डालिए

राणा रतन सिंह चित्तौड़ ( 1302 ई. - 1303 ) राजस्थान के इतिहास में गुहिलवंशी…

4 days ago

हम्मीर देव चौहान का इतिहास क्या है ? hammir dev chauhan history in hindi explained

hammir dev chauhan history in hindi explained हम्मीर देव चौहान का इतिहास क्या है ?…

1 week ago

तराइन का प्रथम युद्ध कब और किसके बीच हुआ द्वितीय युद्ध Tarain battle in hindi first and second

Tarain battle in hindi first and second तराइन का प्रथम युद्ध कब और किसके बीच…

1 week ago

चौहानों की उत्पत्ति कैसे हुई थी ? chahamana dynasty ki utpatti kahan se hui in hindi

chahamana dynasty ki utpatti kahan se hui in hindi चौहानों की उत्पत्ति कैसे हुई थी…

2 weeks ago

भारत पर पहला तुर्क आक्रमण किसने किया कब हुआ first turk invaders who attacked india in hindi

first turk invaders who attacked india in hindi भारत पर पहला तुर्क आक्रमण किसने किया…

3 weeks 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