C++ Lecture 2
C++ Lecture 2
A compiler is a program that converts the instruction of high-level language into machine
Instructor: M Altaf 2 Course: C++
language as a whole. A program written in high level language is called source program.
The complier converts the source program into machine code. The machine code is known
as object program. The object program can be executed may times.
The compiler checks each statement in the source program and generates machine
instructions. Compiler can translate the programs of only those languages for which it is
written. For example, C compiler can translate only those programs that are written in C
language.
Interpreter:
An interpreter is a program that translates one instruction of the program at a time. It
converts the instruction into machine language and executes, ` it then moves to the next
instruction of the program. It displays the error message if there is any error in the
instruction.
The advantage of interpreters over compiler is that an error is found immediately. The
programmer can correct the errors during program development.
The disadvantage of interpreter is that it is not very efficient, the interpreter does not produce
and object program. It converts the instructions into machine language each time it is
executed. BASIC language uses interpreter.
Assembler:
An assembler is a translating program that translates the instruction of assembly language
into machine language.