Q: What is a compiler's role in programming?
-
A
To execute the code directly on the hardware
-
B
To translate high-level code into machine code
-
C
To manage the memory for a program
-
D
To assist in writing pseudo-code
B
Answer:
B
Explanation:
A compiler is a specialized program that converts the entire source code written in a high-level programming language into machine code, which can be executed by the computer's CPU. This translation process is essential because computers cannot directly understand high-level programming languages; they can only process machine language. The compilation process includes syntax analysis, optimization, and code generation, which results in a standalone executable file. By compiling code into machine language, the compiler allows for efficient program execution and enables developers to use high-level languages to write applications that run on different hardware platforms.
Related Topic:
Share Above MCQ