What is the primary function of a compiler in computer programming?
Think about how a program written by a human becomes understandable by a computer.
A compiler converts the entire source code into machine code before execution, enabling the computer to run the program efficiently.
What is the typical output produced by a compiler after processing source code?
Consider what you run on your computer after compiling a program.
The compiler produces an executable file containing machine code that the computer can run directly.
Which statement correctly explains a key difference between a compiler and an interpreter?
Think about when the translation happens in each case.
Compilers translate the whole program into machine code before running it, whereas interpreters translate and run code one line at a time.
Why might a programmer choose to use a compiler instead of an interpreter?
Consider the performance difference between compiled and interpreted programs.
Compiled programs run faster because the translation to machine code happens once before execution, avoiding repeated translation during runtime.
Which of the following correctly orders the main stages of a compiler?
Think about how the compiler processes code from raw text to machine instructions step by step.
The compiler first breaks code into tokens (lexical), then checks structure (syntax), then meaning (semantic), and finally creates machine code (code generation).