Preprocessor directives are lines included in the code of programs preceded by a hash sign ( # ). The preprocessors are the directives, which give instructions to the compiler to preprocess the information before actual compilation starts. Preprocessing directives are lines in your program that start with # . The # is followed by an identifier that is the directive name. The Whitespace is also allowed before and after the #.
#include <iostream> #define PI 3.14 #define rectangle(length, breadth) (length * breadth) #define createString(s) #s #define concat(a, b) a ## b using namespace std; //Preprocessor Directive in C++ Programming int main() { cout<<"Area of a circle : "<<PI*5*5<<endl; int length = 20, breadth = 5, area; area=rectangle(length,breadth); cout << "Area of a rectangle is: " << area<<endl; cout<<"New String : "<<createString(Tutor Joes)<<endl; int ab=100; cout<<"The Value of AB : "<<concat(a,b)<<endl; cout<<"__LINE__ :" << __LINE__ << endl; cout<<"__FILE__ :" << __FILE__ << endl; cout<<"__DATE__ :" << __DATE__ << endl; cout<<"__TIME__ :" << __TIME__ << endl; cout<<"__cplusplus:"<<__cplusplus<<endl; return 0; }
Area of a circle : 78.5 Area of a rectangle is: 100 New String : Tutor Joes The Value of AB : 100 __LINE__ :17 __FILE__ :C:\Users\Tutor Joes\Desktop\Sandhiya\sample.cpp __DATE__ :Mar 18 2022 __TIME__ :16:21:54 __cplusplus:201402To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions