C Preprocessor Questions
Practice C Preprocessor MCQs with answers and explanations. Page 2 of 2.
Category
C Programming
Topic
C Preprocessor
Page
2 / 2
Mode
Practice
Questions
Open any question to view the answer and explanation.
Semantics check: Can #undef be applied only to a macro that was previously #define’d?
Open
View answer
After preprocessing, do macro names and their definitions remain in the compiler’s input, or are they removed from the expanded source?
Open
View answer
Must every valid C program contain at least one preprocessor directive?
Open
View answer
Content of typical C header files: Do headers commonly contain macros, structure declarations, and function prototypes?
Open
View answer
C preprocessor macros – does a macro “receive control” at runtime?
Consider the statement: “In a macro call the control is passed to the macro.” Decide whether this is accurate in C programming.
Open
View answer
C preprocessor directives – are they messages from the compiler to the linker?
Evaluate the accuracy of this statement about the build pipeline.
Open
View answer
C macro naming conventions – must macros always be written in uppercase letters?
Judge the correctness of this style-related statement.
Open
View answer
C preprocessor – are macros with arguments permitted?
Decide whether parameterized (function-like) macros are allowed in standard C.
Open
View answer
C macros and scope – do macros have local scope by default?
Evaluate the statement about the visibility and lifetime of macro definitions.
Open
View answer
Preventing multiple inclusion of the same header – is there a standard way?
Decide whether C provides mechanisms to avoid including a file twice.
Open
View answer
Macro-defined infinite loop – will this program print the message endlessly?
#include <stdio.h>
#define INFINITELOOP while(1)
int main()
{
INFINITELOOP
printf("CuriousTab");
return 0;
}
Open
View answer
Conditional compilation with #ifdef – does this program compile and what is printed?
#include <stdio.h>
int main()
{
#ifdef NOTE
int a; a = 10;
#else
int a; a = 20;
#endif
printf("%d
", a);
return 0;
}
Open
View answer
typedef and preprocessor syntax – would this construct work?
Code to assess: typedef #include l;
Open
View answer
Mutually recursive macro definitions – will this program compile?
#include <stdio.h>
#define X (4+Y)
#define Y (X+3)
int main()
{
printf("%d
", 4X + 2);
return 0;
}
Open
View answer
In C/C++, is it strictly necessary for a header file to use the .h extension, or can headers be named without .h (for example, project-specific headers or C++ standard headers like <vector>)? Provide the most accurate answer and rationale.
Open
View answer
C language: Will this program compile successfully and what does the concatenation of adjacent string literals do?
#include<stdio.h>
int main()
{
printf("India" "CURIOUSTAB
");
return 0;
}
Open
View answer
If the same header file is included twice in a C project, will it always cause an error, or can compilation still succeed? Choose the most accurate statement about multiple inclusion and header guards.
Open
View answer
Practice smarter
Solve a few questions daily and revisit weak topics regularly to improve accuracy.