To compile and run a C language program, you need a C compiler. To setup a C language compiler in your Computer/laptop, there are two ways:
We will recommend you to use Turbo C IDE, oldest IDE for c programming. It is freely available over internet and is good for a beginner.
Step 1 : Open turbo C IDE(Integrated Development Environment), click on File and then click on New
If you do not wish to setup an IDE and prefer the old school way, then download the C compiler which is called
gcc from the gcc website https://gcc.gnu.org/install/
Once you have downloaded and installed the
gcc compiler, all you have to do it, open any text editor, copy and paste the C program code from the previous tutorial, and save it with the name hello.c
Open Command prompt or Terminal(if you use Ubunut or Mac OS), and go to the directory where you have saved the hello.c program file.
Type the command
gcc hello.c to compile the code. This will compile the code, and if there are no errors then it will produce an output file with name a.out(default name)
Now, to run the program, type in
./a.out and you will see Hello, World displayed on your screen.
$ gcc hello.c $ ./a.out
You must be thinking why it is a 2 step process, first we compile the code and then we run the code. So, compilation is the process where the compiler checks whether the program is correct syntax wise, and there are no errors in the syntax.
When we run a compiled program, then it actually executes the statements inside the