When learning C programming, the “Hello, World!” program is traditionally your first step. It’s simple, easy to understand, and teaches the basic structure of a C program.
What Is the "Hello, World!" Program?
It’s a basic program that displays the message:
Hello, World!
This program helps you understand the syntax and structure of a C program.
Code: Hello World in C
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
Step-by-Step Explanation
Line
Explanation
#include <stdio.h>
Preprocessor directive. Includes Standard Input Output library so you can use printf()
int main()
The main function – where the program starts running
{ ... }
Curly braces define the body of the function
printf("Hello, World!\n");
Prints text to the screen. \n means new line
return 0;
Ends the program and returns control to the OS
How to Run Hello World (Step-by-Step)
On Windows (using Code::Blocks)
Open Code::Blocks
Create a new project → Console Application → Select C
Paste the above code
Click Build and Run
On Linux / macOS (using terminal)
Open a terminal
Create a file:
nano hello.c
Paste the code
Compile:
gcc hello.c -o hello
Run:
./hello
Output
Hello, World!
Congratulations — You’ve written your first C program!
Best Practices
Always include comments in your code
Keep code indented and clean
Use return 0; at the end of main() to indicate successful execution