Let us learn how to print hello world in C programming language in Linux Ubuntu operating system. We have also explained how to execute hello world C program in Linux Ubuntu.
The hello world program simply displays a Hello World to the end user. It is the very first program that every beginner programmer starts with.
This is helpful as this program is usually very simple to implement and it also helps you understand the basic elements and syntax of that particular programming language.
Alternatively, you can also print hello world in C programming without using the semicolon. Check it out here.
How To Execute Hello World in C Programming?
- Create a new text document using gEdit text editor in Linux operating system.
- Copy any of the following hello world programs, and paste it into your text document.
- Save the document with a .c extension.
- Open the Linux terminal by using the shortcut command Ctrl + T.
- Locate to the .c document directory by using the cd command as shown in the output at the bottom.
- Since GCC is the default compiler in Linux, type gcc filename.c command.
- To run the object file, type ./a.out command and it’s going to display the output.
If you’re in Microsoft Windows environment, please download a C compiler and have fun with C programming.
Note: This C program to write hello world program is compiled with GNU GCC compiler on Linux Ubuntu 14.10 operating system.
Method 1: Display Hello World in C Programming
1 2 3 4 5 6 7 | #include<stdio.h> void main() { printf("Hello World\n"); printf("\n"); } |
Method 2: Print Hello World C Program using Command Line Arguments
1 2 3 4 5 6 | #include <stdio.h> int main(int argc, char *argv[printf("Hello World")]) { return 0; } |
Method 3: C Program To Print Hello World using Strings
1 2 3 4 5 6 7 8 9 | #include<stdio.h> int main() { char str[] = "Hello World"; printf("%s\n",str); printf("\n"); return 0; } |
Method 4: C Program To Display Hello World using Macros
1 2 3 4 5 6 7 8 9 | #include <stdio.h> #define STRING "Hello World" int main() { printf(STRING); return 0; } |
Output

If you have any compilation errors or doubts about this C program to display hello world, let us discuss it in the comment section below.
Find more about Hello World program on Wikipedia.
You have used Hello World statement in Command Line Hello World Code. We have to print hello world in Command Line as arguments.
We have passed default values here. If you want then you can remove this default value and pass your Hello World statement via command line. No issues in that.
It is advisable to have return 0; statement at the end if you’re using int main() as it is considered as one of the best practices to program in C language.
Excellent work brother.