Are you interested in writing a basic “Hello World” program using the C programming language?If yes, then this post is for you.

Here is an example of how you can write, compile and execute a very simple C program in Ubuntu Linux. You can use any editor. For this example, I’ll use GEdit.

1. Fire up the terminal, and type:

$ gedit first.c

2. Type some code, or just past this “Hello World” example:

#include<stdio.h>
main()
{
  printf("Hello World\n");
}

3. Once you have written and saved your code, return to terminal and compile:

$ gcc first.c

4. A file named a.out will be created in the same directory that you saved your program in.This is the default name of the executable that gcc creates. You can change the name of your executable, by adding the -o option followed by the name of the executable.

$ gcc -o hello first.c

5. You should now have an executable by the name hello. To execute your program type:

$ ./hello

6. If everything went well, you should see the following output:

Hello World

Congratulations! You just wrote a simple C program.