Introduction
C++ is a powerful programming language for your competitive programming. To get flawless control in this language, you can refer to this amazing article on Coding Ninjas Studio. What are preprocessors? Preprocessors are powerful tools which help in the inclusion of header files, line control, conditional compilation, and macro expansion. In C/C++ we have a lot of preprocessors. In this blog, we will be looking at the #ifndef preprocessor.
The #ifndef preprocessor directive checks for the conditional compilation. It checks if the macro is defined by #define or not. If the macro is not defined by #define, then it executes the code. If it is defined by #define, then the #else is executed if present.
Also see: C Static Function, and Tribonacci Series
Syntax
#ifndef MACRO
//code
#endif
Syntax with #else:
#ifndef MACRO
//successful code
#else
//else code
#endif