Introduction to Programming MCQs with Answers
Practice important Introduction to Programming MCQs with answers and explanations.
Multiple Choice Questions
Q401: What happens if you redefine a macro without undefining it first?
- A: No impact
- B: Compilation error
- C: Program runs slower
- D: The macro is updated automatically
View Answer
B
Q402: What is the main advantage of using macros over functions?
- A: Easier to write
- B: Saves memory
- C: Faster execution
- D: Easier debugging
View Answer
C
Q403: Why should variable names not start with an underscore?
- A: It is reserved for internal use
- B: It is not allowed
- C: It causes syntax errors
- D: It is harder to read
View Answer
A
Q404: What is the purpose of #pragma directive?
- A: It is used for debugging
- B: It is used to suppress warnings
- C: It is used to set compiler-specific instructions
- D: It is used to define constants
View Answer
C
Q405: How can you execute a block of code only when a macro is defined?
- A: Use #ifdef followed by #endif
- B: Use #define followed by #endif
- C: Use #undef followed by #ifdef
- D: Use #include followed by #pragma
View Answer
A
Q406: What directive is used to include header files in the source code?
- A: #define
- B: #ifdef
- C: #include
- D: #undef
View Answer
C
Q407: Which of the following is not a preprocessor directive in C?
- A: #pragma
- B: #assert
- C: #endif
- D: #execute
View Answer
D
Q408: What is dynamic memory allocation?
- A: Allocation of memory at runtime
- B: Allocation of memory at compile time
- C: Allocation of memory on stack
- D: Allocation of memory in registers
View Answer
A
Q409: Which function is used to allocate memory dynamically in C?
- A: malloc()
- B: calloc()
- C: realloc()
- D: All of the above
View Answer
D
Q410: What type of pointer is returned by dynamic memory allocation functions in C?
- A: int pointer
- B: void pointer
- C: char pointer
- D: float pointer
View Answer
B