First C Program

Creating your first C program is a great way to get started! Here’s a simple "Hello, World!" program, which is a traditional first program in many programming languages.


Example: Hello, World!

1. Write the Code: Open your text editor or IDE and write the following code:

c
#include
int main() {
    printf("Hello, World!\n");
    return 0;
}


2. Save the File: Save the file with a .c extension, for example, hello.c.

3. Compile the Program: Open your terminal (or command prompt) and navigate to the directory where you saved the file. Then, compile the program using:

bash
gcc hello.c -o hello


4. Run the Program: Execute the compiled program:

bash
    ./hello  # On Linux/macOS
    hello.exe  # On Windows


Output:

When you run the program, you should see the following output:

Hello, World!




  • To Share this Link, Choose your plateform


Our Other Tutorials