Foundations-of-Computer-Science practice question 15 of 15
Why are comments used in source code?
Full set: 71 questionsComments are annotations within the source code that are intended for human readers. Their primary purpose is to clarify the code's logic, document its purpose, or provide usage instructions. Compilers and interpreters are designed to ignore comments, so they have no effect on the final executable program. This allows developers to write explanatory text that improves code maintainability and readability without altering its functionality.
B. Comments are ignored during compilation, but they do not cause the compiler to skip the entire source file.
C. Comments are plain text and have no role in cryptographic operations like encrypting variables. Encryption is handled by specific code logic.
D. While comments explain code, they are not a substitute for clear, meaningful variable and function names, which is a core principle of clean code.
1. Kernighan, B. W., & Ritchie, D. M. (1988). The C Programming Language (2nd ed.). Prentice Hall. (Section 1.2, p. 9, introduces comments / ... / as notes that are ignored by the compiler.)
2. Python Software Foundation. (n.d.). Python 3.12.3 documentation. The Python Tutorial, Section 3.1.1: Numbers. (Describes comments starting with the hash character # and explains they are for clarifying code and are ignored by the interpreter.)
3. Martin, R. C. (2008). Clean Code: A Handbook of Agile Software Craftsmanship. Prentice Hall. (Chapter 4: "Comments," emphasizes that comments exist to explain code that cannot be made self-explanatory.)
Keep practicing
Take the free Foundations-of-Computer-Science practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other Foundations-of-Computer-Science practice questions
- Question 1What is the purpose of a parameter in a function definition?
- Question 2What is the primary purpose of an operating system?
- Question 3Which action is taken if the first number is the lowest value in a selection sort?
- Question 4What will the expression fam[3:6] return?
- Question 5What will the output be of this line?
- Question 6Which aspect is excluded from a NumPy array’s structure?
