Pre-Processor Directives in C++

The Pre-Processor Directives(PPD) give instruction to the compiler to process the information before compilation of program. All preprocessor directives(PPD) are written from first row and first column of program. Some important PPD are as follows:-
प्री-प्रोसेसर डायरेक्टिव(PPD) के द्वारा कम्पाइलर को यह निर्देश दिए जाते है कि वह कुछ महत्वपूर्ण जानकारियों को प्रोग्राम कम्पाइल करने से पूर्व प्रोसेस करे। सभी प्री-प्रोसेसर डायरेक्टिव(PPD) को प्रोग्राम की पहली लाइन एवं पहले कॉलम से लिखा जाता है। कुछ महत्वपूर्ण PPD निम्न है :-

1) #include :-
This PPD includes important header files in our c++ program.
इस PPD के द्वारा महत्वपूर्ण हैडर फाइल्स को हमारे C++ प्रोग्राम में जोड़ा जाता है। 
Syntax:-
#include<file_name>
#include"file_name"

Example:-
#include<iostream.h>
OR
#include<iostream>
OR
#include"iostream"

2.) #define:-
The #define PPD creates  a macro (symbolic constants). Here macro name is replaced with macro expansion before the program is compiled.
इस PPD के द्वारा एक मैक्रो (सिंबॉलिक कांस्टेंट) तैयार किया जाता है। यहाँ प्रोग्राम कम्पाइल करने से पूर्व, मैक्रो का नाम , मैक्रो एक्सपेंशन से प्रतिस्थापित किया जाता है। 
Syntax:-
#define macro_name macro_expansion

For example:
#include <iostream>
#define PI 3.14159
int main ()
{
float r,area;
cout<<"Enter radius"<<endl;
cin>>r;
area=PI*r*r;
cout << "Area of Circle is :" <<area << endl;
return 0;
}

3.) In addition, some other conditional PPD like #ifdef #if #endif etc.
इसके अतिरिक्त कुछ अन्य कंडीशनल PPD #ifdef #if #endif इत्यादि होते है। 

No comments:

Post a Comment