Quick links: C-Tricks HR Interview Que. Code Snippets C Programs C++ Programs Java Programs PHP Examples

Home » C programming language

C language #if, #elif, #else, #endif Pre-processor with Example

#if, #elif, #else, #endif

The pre-processor directives #if, #elif, #else, #endif are used as conditional compilation, whenever we need to compile specify code segments, we use these pre-processor directives.

Let’s consider the following example

#include <stdio.h>

#define ENG_US	1
#define ENG_UK	2
#define FRENCH	3

#define LANGUAGE ENG_UK

int main(){
	
	#if LANGUAGE==ENG_US
		printf("Selected language is: ENG_US\n");
	#elif LANGUAGE==ENG_UK
		printf("Selected language is: ENG_UK\n");
	#else 
		printf("Selected language is: FRENCH\n");
	#endif
	
	return 0;
}

Output

Selected language is: ENG_UK

Sponsored Links




COMMENTS

Solved programs


Sponsored Links


Most viewed pages


Featured posts
C Tips and Tricks

Keywords (like Linux, Java, Oracle etc) used in this website are the trademarks of their respective owners/company. This website is not affiliated to any company. The tutorials are designed by includehelp Team with the help of well known books and other online resources. These Tutorials are free for all, for learning purposes only. Enjoy learning:)
Copyright © 2015 - 2016. All Rights Reserved.