Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
543 views
in Computer by (69.8k points)

Explain the following directives: #elif #pragma #error

1 Answer

+1 vote
by (69.2k points)
selected by
 
Best answer

(i) ‘#elif’ is a preprocessor directive that provides alternate test facility. `#elif' stands for “else if”. Like `#else', it goes in the middle of a conditional group and subdivides it; it does not require a matching `#endif' of its own. Like `#if', the `#elif' directive includes an expression to be tested. The text following the `#elif' is processed only if the original `#if'-condition failed and the `#elif' condition succeeds. 

For example, suppose we have following set of statements: 

Using `#elif', we can abbreviate this as follows:

#if X == 1 

... 

#elif X == 2

... 

#else /* X != 2 and X != 1*/

... 

#endif /* X != 2 and X != 1*/

(ii) #pragma is an implementation oriented directive that specifies various instructions to be given to the compiler. 

#pragma name

causes compiler to perform “name”

(iii)#error is a preprocessor directive used to produce diagnostic messages during debugging.

#error message

causes the compiler to display the error message and terminate processing on encountering this directive. 

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...