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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL







Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.