Sail E0 Webinar

MCQs

Total Questions : 43 | Page 2 of 5 pages
Question 11.

Macros with arguments are allowed


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True

True, A macro may have arguments.

Example: #define CUBE(X)(X*X*X)


Question 12.

Preprocessor directive #ifdef .. #else ... #endif is used for conditional compilation.


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True

True, these macros are used for conditional operation.

#if <constant - expression>

#elf <constant - expression>

#endif


Question 13.

Every C program will contain at least one preprocessor directive.


  1.    True
  2.    False
 Discuss Question
Answer: Option B. -> False

False, the preprocessor directive is not mandatory in any c program.


Question 14.

Macros have a local scope.


  1.    True
  2.    False
 Discuss Question
Answer: Option B. -> False

False, The scope of macros is globals and functions. Also the scope of macros is only from the

 point of definition to the end of the file.


Question 15.

A macro must always be defined in capital letters.


  1.    True
  2.    False
 Discuss Question
Answer: Option B. -> False

FALSE, The macro is case insensitive.


Question 16.

Macro calls and function calls work exactly similarly.


  1.    True
  2.    False
 Discuss Question
Answer: Option B. -> False

False, A macro just replaces each occurrence with the code assigned to it. e.g. SQUARE(3) 

with ((3)*(3)) in the program.

A function is compiled once and can be called from anywhere that has visibility to the funciton.


Question 17.

A preprocessor directive is a message from programmer to the preprocessor.


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True

True, the programmer tells the compiler to include the preprocessor when compiling.


Question 18.

There exists a way to prevent the same file from getting #included twice in the same program.


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True

True, We can prevent the same file from getting included again by using a preprocessor directive called #ifndef (short for "if not defined") to determine whether we've already defined a preprocessor 

symbol called XSTRING_H. If we have already defined this symbol, the compiler will ignore the rest 

of the file until it sees a #endif (which in this case is at the end of the file).

#ifndef XSTRING_H

#define XSTRING_H defines the same preprocessor symbol,

Finally, the last line of the file, #endif


Question 19.

If the file to be included doesn't exist, the preprocessor flashes an error message.


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True

True, the included file does not exist it will generate the error.


Question 20.

Preprocessor directive #undef can be used only on a macro that has been #define earlier


  1.    True
  2.    False
 Discuss Question
Answer: Option A. -> True

True, #undef can be used only on a macro that has been #define earlier

Example: #define PI 3.14

We can undefine PI macro by #undef PI


Latest Videos

Latest Test Papers