To compile C program on Linux terminal
Write any C program in text editor and save as filename.c
In following example, I have saved this file on my Desktop.
To run this program, you have to compile it first.
$ gcc -o compiled-filename /home/user/Desktop/filename.c
Where compiled-filename is the name of compiled file, it can be anything.
This will generate a compile copy of your program as a name compiled-filename in same directory where you ran the above command.
Now create output copy of your program.
Following command generate a output file of your program in same directory.
$ gcc /home/user/Desktop/filename.c
Now run your program.
where a.out is output copy of your program.
Alternatively you can run compiled copy of your program.