To ensure that your compiler is installed type the given command to find its location and version number:
$ whereis gcc
Output:
$ which gcc
Output:
$ gcc --version
Output:
To start writing your source code, open a text editor by typing
$ gedit program.c
Write the C source code given below in text editor:
#include
main()
{
printf("This is my first C program on ubuntu\n");
}
Close the editor window.
Output:
The following command will invoke the GNU C compiler to compile the file program.c and output (-o) the result to an executable called program.
$ gcc -o program program.c
Output:
Type the given command to display output:
$ ./program
Output:
The above guide demonstrates how to write your first C program in Linux by installing GNU C compiler. To know more about C programming in Linux explore different books and practice more source code related to different topics in C programming.