C Arrays Quiz – 20 Questions with Answers
20 questions · 15 min · Medium
Test your knowledge of the C preprocessor with 15 questions covering preprocessor directives, macros, header files, conditional compilation, include files, and predefined macros.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
20 questions · 15 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
B. To process source code before compilation
The C preprocessor processes directives and performs tasks such as macro expansion and header inclusion before the source code is compiled.
C. #
C preprocessor directives begin with the # symbol, such as #include and #define.
B. #define
The #define directive is used to define object-like and function-like macros.
B. Defines a macro named PI
The #define directive creates a macro. During preprocessing, occurrences of PI are replaced according to the macro definition.
A. #include
The #include directive tells the preprocessor to include the contents of another file at that point in the source.
A. #include <stdio.h>
Angle brackets are commonly used with #include for system or standard headers, such as #include <stdio.h>.
B. #include "myheader.h"
Double quotes are commonly used when including user-defined headers, such as #include "myheader.h".
A. #ifdef
#ifdef conditionally includes code when the specified macro has been defined.
B. #ifndef
#ifndef means 'if not defined' and conditionally includes code when the specified macro is not defined.
B. Removes the definition of a macro
The #undef directive cancels the current definition of a macro.
B. #else
The #else directive specifies the alternative section of code when the preceding conditional preprocessing condition is false.
B. #endif
The #endif directive marks the end of a conditional preprocessing block started by directives such as #if, #ifdef, or #ifndef.
A. They can represent reusable code-like substitutions
Function-like macros can accept arguments and perform textual substitution during preprocessing, allowing reusable code patterns.
A. __FILE__
The predefined macro __FILE__ expands to the name of the current source file as a string literal.
A. __LINE__
The predefined macro __LINE__ expands to the current source line number and is commonly useful for diagnostics and debugging.