C++ Certified Associate Programmer (CPA-21-02) — Question 6
Which of the following statements are true? (Choose two.)
Answer options
- A. A void function can return a floating-point value
- B. A function can be defined inside another function
- C. A typed function may have any number of return statements, each returning a different value
- D. A void function cannot contain any return expression statement
Correct answer: C, D
Explanation
Option C is correct because a typed function can have multiple return statements that can return different values. Option D is also correct as a void function is designed not to return a value, hence it cannot have a return expression. Options A and B are incorrect because a void function cannot return a value and while a function can be defined inside another function, it's not universally applicable in all programming languages.