Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


C++ Programming Code Examples

Learn C++ Language

#ifndef Directive in C++ Programming Language

#ifndef Directive in C++
The #ifndef directive of the C++ Programming Language helps in allowing the conditional compilation. The C++ Programming Language's preprocessor helps in determining only if the macro provided is not at all existed before including the specific subsequent code in the C++ compilation process. The #ifndef preprocessor only checks If the specific macro is not at all defined with the help of the #define directive. If the condition is TRUE then it will be helpful in executing the code otherwise the else code of the #ifndef will be compiled or executed only if present.
Syntax for #ifndef Directive in C++
#ifndef MACRO //Code Statements #else //Code Statements which are used to include if the specific token is defined #endif
#ifndef MACRO
The #ifndef works for the opposite condition of the #ifdef directive of the C Programming Language. The "MACRO" definition should not be defined for the specific preprocessor which is used to include the C Programming Source Code into the specific compiled application. The #ifndef must be ended with the #endif directive of the C Programming Language.
#else directive
If the #ifndef does not accept then else code statements will be printed which are actually used in including the specific which is defined.
#endif directive
The #endif directive of the C Programming Language helps in closing the #ifndef directive of the C Programming Language. It is must and should end only with the #endif C Source code directive. The $ifndef directive usually checks/helps in seeing the specific identifier is currently not defined or not. The #ifndef preprocessor of the C Programming Language helps in allowing the conditional compilations. The preprocessor directive helps in determining whether the macro is existed or not before the subsequent code in the compilation process/ procedure. The #ifndef directive and #if !defined identifier are equivalent directives of the C Programming Language. The #ifndef directive helps in checking the opposite condition of the #ifdef directive of the C Programming Language. If the specified identifier is not even defined or definition is removed with the help of the #undef then the condition is TRUE for nonzero value or else the condition will be FALSE.
/* #ifndef Directive in C++ language */ #define Module101 #define MyVersion 1.1 #include<iostream> usingnamespace std; int main(void) { cout<<"Sample using #define, #ifdef, #ifndef"<<endl; cout<<" #undef, #else and #endif..."<<endl; cout<<"-------------------------------------"<<endl; #ifdef Module102 cout<<"\nModule102 is defined."<<endl; #else cout<<"\nModule102 is not defined."<<endl; #endif #ifndef MyVersion cout<<"\nMyVersion is not defined"<<endl; #else cout<<"\nMyVersion is "<<MyVersion<<endl; #endif #ifdef MyRevision cout<<"\nMy Revision is defined\n"<<endl; #else cout<<"\nMyRevision is not defined!"<<endl<<endl; #endif #undef MyVersion #ifndef MyVersion cout<<"MyVersion is not defined"<<endl<<endl; #else cout<<"MyVersion is "<<MyVersion<<endl; #endif return 0; }




To convert "Hexadecimal" number to "binary" number in C++, you have to ask to the user to enter the hexadecimal number to convert it into binary number to display the equivalent