What is the primary purpose of a header file in C++?

Options

  • A. To provide declarations and function prototypes
  • B. To execute the program
  • C. To store only program output
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

A. To provide declarations and function prototypes

Detailed Explanation

Correct Answer: Option A

Explanation: Header files commonly contain declarations, function prototypes, class declarations, and constants that can be shared across source files.