Which character is used to represent a comment in C code?
a) #
b) //
c) /* */
d) Both b and c
Answer:
d) Both b and c
Explanation:
In C, comments can be represented in two ways. Single-line comments are written using //
, while multi-line comments are enclosed within /* */
. Comments are ignored by the compiler and are used to include notes, explanations, or temporarily disable parts of the code for debugging.
Understanding how to use comments effectively is crucial for writing clear, maintainable, and well-documented code.