Your First C Program - Hello, World!


Congratulations on starting your journey into C programming! "Hello, World!" is the traditional first program that beginners write when learning a new programming language. In this tutorial, you'll create your first C program, which will display "Hello, World!" on the screen.

Writing the "Hello, World!" Program

Open a text editor and create a new file, and then enter the following C code:

#include <stdio.h>
int main() {
printf("Hello, World!\\n");
return 0;

This code is a simple C program. It includes the standard input/output library (

). The program defines a
function, which is the entry point of every C program. Inside the
function, the
function is used to display "Hello, World!" on the screen. Finally, the
return 0
statement is used to indicate that the program has run successfully.

Compiling and Running the Program

Now that you've written the code, you need to compile and run it:

  1. Save the file with a
    extension, such as
  2. Open your command prompt or terminal.
  3. Navigate to the directory where you saved
  4. Compile the program using the following command:
gcc hello.c -o hello
  1. Run the program using this command:

If everything is set up correctly, you should see "Hello, World!" printed on the screen.


Writing and running your first C program is a significant milestone in your programming journey. "Hello, World!" is the first step in understanding the basic structure of C programs and how to compile and run them. From here, you can explore more complex C programming concepts and applications.