Discussion
How are the constants declared?
Answer: C
Correct answer: both const keyword and #define preprocessor
Both mechanisms are used, and they work quite differently. #define is a preprocessor directive performing textual substitution before compilation: the name has no type, no scope and no address, and the compiler never sees it.
const qualifies an actual object, which has a type, obeys the ordinary scoping rules, occupies storage and is visible to the debugger. const is generally preferred for that reason, though #define is still needed where a value must be a constant expression usable in contexts such as an array bound in older C.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development