Difficulty: Medium
Correct Answer: interpreter
Explanation:
Introduction / Context:
High level programming languages such as Python, JavaScript, or BASIC are not directly understood by the CPU. Translators are required to convert high level code into machine code or an intermediate form. There are two main approaches: compilation, which translates the whole program before execution, and interpretation, which processes the program line by line. This question tests your understanding of which translator executes one statement at a time as it is translated.
Given Data / Assumptions:
Concept / Approach:
A compiler reads the entire source program, checks for errors, and translates it into machine code or an intermediate form as a whole unit. Once compiled, the resulting executable can run repeatedly without further translation. An interpreter, on the other hand, reads the source code line by line or statement by statement, translates each line, and immediately executes it. It does not usually produce a separate stand alone executable file. The term “converter” is too vague and is not the standard name of such a translator, and “instructions” simply refers to commands, not a translator. Therefore, the translator that converts and executes one statement at a time is an interpreter.
Step-by-Step Solution:
Step 1: Recall what a compiler does.
A compiler translates the whole program into machine code before execution.
Step 2: Recall what an interpreter does.
An interpreter reads a statement, translates it, and executes it immediately, then moves to the next one.
Step 3: Compare these behaviours with the wording of the question.
The question clearly mentions converting and executing one statement at a time.
Step 4: Recognise that this is the behaviour of an interpreter.
Step 5: Select “interpreter” as the correct option.
Verification / Alternative check:
Programming language textbooks often present a table comparing compilers and interpreters. For interpreters, they emphasise that the program is executed line by line, which allows faster testing but slower final execution. Languages like Python are often described as interpreted because their code is executed statement by statement by an interpreter. Compilers, such as those used for C or C++, usually generate a complete executable before running anything. No standard term “converter” is used to specifically describe compilers or interpreters, and “instructions” obviously is not a translator program. This confirms that the question is referring to an interpreter.
Why Other Options Are Wrong:
Option A (compiler): Compilers translate the entire source program in one go and do not execute each statement as soon as it is translated.
Option C (converter): A general word that does not correspond to a specific type of programming language translator.
Option D (instructions): Refers to commands or statements themselves, not to a program that translates or executes them.
Common Pitfalls:
Learners sometimes confuse compilers and interpreters because both translate high level code. They may also think that compilers are faster because they are associated with compiled languages but forget the difference in when translation occurs. To avoid confusion, remember the key distinction: an interpreter translates and executes one statement at a time, while a compiler translates the entire program first and then executes the compiled code.
Final Answer:
The translator that converts and executes one statement at a time is an interpreter.
Discussion & Comments