What is compiler ?
Since computer is an electronic device, it understands only electric signal. For computer, to do some task all the instructions are to be fed to the computer and all the instructions must be converted into electric signal. Generally, low voltage signal is represented by binary '0' and high voltage signal is represented by binary '1'. For us, as a programmer, writing programs using binary 0 and binary 1 is not feasible. It will take a lot of time to design and debug the program. Hence we use high level programming languages to design program which are easy to understand, design and debug. Since computer wont understand high level languages, we need a translator which will translate the program in other language.
Translator is a program which takes as input program written in one programming language and gives as output an equivalent program in some other programming language. The language used in the input program is called source language and the language of the output program is called target language. Similarly the input program is called source code and the output program is called target code or object code.
Compiler is a translator, which translates program written in high level language to an equivalent program in low level language.