Skip to main content

Important Introduction to Programming Short Questions

Chapter: 23
Question 1:
What is the effect of the #elif directive?
Answer: It provides an additional condition in an #if conditional compilation block.
Chapter: 23
Question 2:
How do you include a file from the current directory?
Answer: Use #include "filename" to include files from the current working directory.
Chapter: 23
Question 3:
What does the #define PI 3.1415926 do?
Answer: It defines a macro PI with the value 3.1415926, which gets substituted wherever PI is used.
Chapter: 23
Question 4:
Why is it beneficial to use #define for constants?
Answer: It centralizes the value definition, making updates easier and reducing errors.
Chapter: 23
Question 5:
How can you prevent macro redefinition errors?
Answer: Use #ifdef to check if a macro is already defined before defining it again.
Chapter: 23
Question 6:
What is the role of the #pragma directive?
Answer: It provides additional compiler-specific instructions or optimizations.
Chapter: 23
Question 7:
What is a parameterized macro?
Answer: A macro that takes arguments and can be used to generate code with different values.
Chapter: 23
Question 8:
How does #include with angle brackets differ from quotes?
Answer: Angle brackets look in standard directories, while quotes look in the current directory.
Chapter: 24
Question 9:
What is dynamic memory allocation?
Answer: Dynamic memory allocation is the process of allocating memory during the runtime of a program, allowing for optimal memory usage based on the actual requirements at runtime.
Chapter: 24
Question 10:
How does dynamic memory allocation differ from static memory allocation?
Answer: Dynamic memory allocation occurs at runtime and adjusts memory usage based on the program's needs, while static memory allocation reserves a fixed amount of memory at compile time, which cannot be changed during execution.