Which of the following is the proper syntax for declaring macros in C?

Which of the following is the proper syntax for declaring macros in C?

a) #define MACRO()
b) #macro MACRO
c) #define MACRO
d) macro_define MACRO

Answer:

c) #define MACRO

Explanation:

The correct syntax for declaring a macro in C is using the #define directive followed by the macro name, and optionally, its replacement text. For example, #define PI 3.14 defines a macro PI with a value of 3.14. Macros are useful for defining constants and function-like macros to simplify repetitive code.

Understanding how to declare and use macros is important for writing efficient and maintainable code in C.

Reference links:

https://www.rameshfadatare.com/learn-c-programming/

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top