A compiler is a program that converts a program written in high-level format (Human understandable) to low-level format (Machine understandable).

High-level format :

#include <stdio.h>
int main()
{
    printf("Hello, world!");
    return 0;
}

Low-level format:

0100100010000111110000
1011100110011100001010
0101100100110100101010
1010100011100011001010
1010100101100011100100

Above, we have seen both high-level and low-level formats of a program to print "Hello world!". The low-level format program is known as Binary language. The high-level format program is a C program.

Why Compiler?

Computers are only capable to execute binary instructions. But for humans, it is very difficult to write a program in binary format. So high-level programming languages like C, Java e.t.c. were introduced to write a program in a human-understandable format. Later by using a compiler, we can convert it to binary format.

Every programming language follows its own set of syntactic rules. As a programmer, we should be aware of those rules before writing a program. Even though you are a good programmer, you may do some mistakes. These mistakes will be reported as syntax errors by the compiler during the translation process or compilation process.