What is the primary function of a compiler?

Options

  • A. To execute source code one statement at a time only
  • B. To translate a source program into a target representation
  • C. To manage database records
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. To translate a source program into a target representation

Detailed Explanation

Correct Answer: B — To translate a source program into a target representation.

Explanation: A compiler translates source code into another representation, such as machine code, object code, assembly code or intermediate code. Execution is a separate process, although some language implementations combine compilation and execution.