Correct Answer:
D. Converts into machine codes
The correct answer is Converts into machine codes. A compiler is a specialized program that translates the entire source code of a high‑level programming language (like C, C++, or Java) into machine code, bytecode, or another lower‑level form that a computer's processor can directly execute.
The Compilation Process
- Translation, Not Execution: The primary job of a compiler is to take human‑readable code and output an executable file of binary machine instructions. This happens once, before the program runs. Running the program is the job of the operating system and the CPU, not the compiler.
- Error Detection: While compilers do find syntax errors (and some logical errors) and report them to the programmer, this is a sub‑function during the translation process. The core task remains the conversion to machine code.
- Linking: Linking libraries is the function of a linker, a separate tool that combines compiled object files with library code to produce the final executable. The compiler generates the object files, but linking is done afterward.
- Types of Compilers: Some compile to native machine code (C, Rust), others to bytecode (Java, which runs on the Java Virtual Machine), but all perform the essential conversion from high‑level to low‑level representation.
Thus, a compiler's main function is to convert source code into machine codes.