---
description: Here, is a Hello World program in C #include //Pre-processor directive void main() //main function declaration { printf(&quot;Hello World&quot;); //to output the string on a display getch (); //t
title: C Hello World Program with Code Example
image: https://www.guru99.com/images/hello-world-program-in-c.png
---

 

[Skip to content](#main) 

**⚡ Smart Summary**

C Hello World program introduces the basic structure of a C program, including preprocessor directives, the main function, and the printf statement. It prints a message to the screen and shows how to compile and run C code.

* 🧱 **Program Structure:** Preprocessor directives, the main function, and statements form every C program.
* 📎 **#include:** Pulls in header files such as stdio.h, where printf is defined.
* 🏁 **main() Function:** The mandatory entry point; int main() returns 0 to signal success.
* 🖨️ **printf:** Outputs text to the screen; every statement ends with a semicolon.
* ▶️ **Run It:** Create a .c file in an IDE, then build and run to print “Hello, World!”.

[ Read More ](javascript:void%280%29;) 

![C Hello World Program](https://www.guru99.com/images/hello-world-program-in-c.png)

## Hello World Program in C

Here, is a Hello World program in C

#include<stdio.h>               // Pre-processor commands

void main()
{
    printf("Hello World\n");    // Print Hello World on the screen
}

Here is the code explanation:

### Pre-processor directive

#include is a pre-processor directive in ‘C.’

**#include <stdio.h>**, stdio is the library where the function **printf** is defined. printf is used for generating output. Before using this function, we have to first include the required file, also known as a header file (.h).

You can also create your own functions, group them in header files and declare them at the top of the program to use them. To include a file in a program, use pre-processor directive

#include <file-name>.h

File-name is the name of a file in which the functions are stored. Pre-processor directives are always placed at the beginning of the program.

### The main function

The main function is a part of every ‘C’ program. We can represent the main function in various forms, such as:

* main()
* int main()
* void main()
* main(void)
* void main(void)
* int main(void)

The empty parentheses indicate that this function does not take any argument, value or a parameter. You can also represent this explicitly by placing the keyword void inside the parentheses.

#include<stdio.h>	// Pre-processor directive
int main()		// main function declaration
{
printf("Hello World");	// to output the string on a display
return 0;		// terminating function
}

In the above example, the keyword int means the function will return an integer value. In this case, the last statement should always return 0.

### The source code

After the main function has been declared, we have to specify the opening and closing parentheses. **Curly brackets { },** indicate the starting and end of a program. These brackets must be always put after the main function. All the program code is written inside these brackets, such as declarative and executable part.

The **printf** function generates the output by passing the text “Hello World!”

The **semicolon ;** determines the end of the statement. In C, each statement must end with a semicolon.

So we have successfully installed the [compiler](https://www.guru99.com/c-gcc-install.html) and now can begin working in ‘C.’ We will write a simple program that will say hello to us. Let’s start.

### RELATED ARTICLES

* [C Conditional Statement: IF, IF Else and Nested IF Else with Example ](https://www.guru99.com/c-if-else-statement.html "C Conditional Statement: IF, IF Else and Nested IF Else with Example")
* [Type Casting in C: Type Conversion, Implicit, Explicit with Example ](https://www.guru99.com/c-type-casting.html "Type Casting in C: Type Conversion, Implicit, Explicit with Example")
* [13 BEST C Programming Books for Beginners (2026 Update) ](https://www.guru99.com/best-c-books.html "13 BEST C Programming Books for Beginners (2026 Update)")
* [Top 40 PowerShell Interview Questions and Answers (2026) ](https://www.guru99.com/powershell-interview-questions.html "Top 40 PowerShell Interview Questions and Answers (2026)")

## How to run C Program

**Step 1)** Create a new Project

[](https://www.guru99.com/images/1/012519%5F1021%5FCHelloWorld1.png)

**Step 2)** In the pop-up,

1. Select File
2. Choose the “C/C++ Source”
3. Click “Go.”

[](https://www.guru99.com/images/1/012519%5F1021%5FCHelloWorld2.png)

**Step 3)** Continue, by clicking on “Next.”

[](https://www.guru99.com/images/1/012519%5F1021%5FCHelloWorld3.png)

**Step 4)** To create the new file, select a “C” file then click on “Next” button to continue.

[](https://www.guru99.com/images/1/012519%5F1021%5FCHelloWorld4.png)

**Step 5)** Set the file path by clicking the “…” button, the explorer window permits to create the C file.

[](https://www.guru99.com/images/1/012519%5F1021%5FCHelloWorld5.png)

**Step 6)** Select the path of your new C File then its name which has .c extension and save it.

[](https://www.guru99.com/images/1/012519%5F1021%5FCHelloWorld6.png)

**Step 7)** Finally, to confirm the C file creation click “Finish.”

[](https://www.guru99.com/images/1/012519%5F1021%5FCHelloWorld7.png)

**Step 8)** Enter the code, save it and compile it by clicking on the “Build & Run “button.

[](https://www.guru99.com/images/1/012519%5F1021%5FCHelloWorld8.png)

Here is the result:

 Hello, World!

## FAQs

⚖️ What is the difference between void main() and int main() in C?

int main() returns an integer status code (usually 0 for success) to the operating system, which is the standard form. void main() returns nothing and is non-standard, though some compilers accept it.

📎 What does #include <stdio.h> do?

It tells the preprocessor to include the standard input/output header file, which declares functions like printf and scanf. Without it, the compiler would not recognize those functions.

🔚 Why does printf need a semicolon at the end?

In C, the semicolon marks the end of a statement. Every executable statement, including printf, must end with one, or the compiler reports a syntax error.

🤖 How can AI help beginners learn C programming?

AI tutors can explain syntax, generate practice exercises, walk through code line by line, and answer questions instantly. This gives beginners immediate, personalized feedback while learning fundamentals like main(), printf, and headers.

🧠 Can AI detect errors in a C Hello World program?

Yes. AI-assisted tools can spot missing semicolons, unclosed braces, a forgotten #include, or an incorrect return type, and explain how to fix each issue, which speeds up debugging for new programmers.

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI 

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.** 

##### Sign up for the newsletter

Subscribe for Free 

You have successfully subscribed.  
Please check your inbox. 

![AI-Newsletter]() Chosen by over **350,000+** professionals 

[Scroll to top ](#wrapper)Scroll to top 

× 

Toggle Menu Close 

Search for: 

Search

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/hello-world-program-in-c.png","url":"https://www.guru99.com/images/hello-world-program-in-c.png","width":"700","height":"250","caption":"Hello World Program in C","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/c-hello-world-program.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/c-programming","name":"C Programming"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/c-hello-world-program.html","name":"C Hello World Program with Code Example"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/c-hello-world-program.html#webpage","url":"https://www.guru99.com/c-hello-world-program.html","name":"C Hello World Program with Code Example","dateModified":"2026-06-30T17:35:58+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/hello-world-program-in-c.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/c-hello-world-program.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/benjamin","name":"Benjamin Walker","description":"I'm Benjamin Walker, an expert in C, C++, and C# programming, providing resources to enhance your coding proficiency and project outcomes.","url":"https://www.guru99.com/author/benjamin","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/benjamin-walker-author.png","url":"https://www.guru99.com/images/benjamin-walker-author.png","caption":"Benjamin Walker","inLanguage":"en-US"},"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"C Programming","headline":"C Hello World Program with Code Example","description":"Here, is a Hello World program in C #include //Pre-processor directive void main() //main function declaration { printf(&quot;Hello World&quot;); //to output the string on a display getch (); //t","keywords":"bigdata, programming, database, server","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/benjamin","name":"Benjamin Walker"},"dateModified":"2026-06-30T17:35:58+05:30","image":{"@id":"https://www.guru99.com/images/hello-world-program-in-c.png"},"copyrightYear":"2026","name":"C Hello World Program with Code Example","subjectOf":[{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is the difference between void main() and int main() in C?","acceptedAnswer":{"@type":"Answer","text":"int main() returns an integer status code (usually 0 for success) to the operating system, which is the standard form. void main() returns nothing and is non-standard, though some compilers accept it."}},{"@type":"Question","name":"What does #include do?","acceptedAnswer":{"@type":"Answer","text":"It tells the preprocessor to include the standard input/output header file, which declares functions like printf and scanf. Without it, the compiler would not recognize those functions."}},{"@type":"Question","name":"Why does printf need a semicolon at the end?","acceptedAnswer":{"@type":"Answer","text":"In C, the semicolon marks the end of a statement. Every executable statement, including printf, must end with one, or the compiler reports a syntax error."}},{"@type":"Question","name":"How can AI help beginners learn C programming?","acceptedAnswer":{"@type":"Answer","text":"AI tutors can explain syntax, generate practice exercises, walk through code line by line, and answer questions instantly. This gives beginners immediate, personalized feedback while learning fundamentals like main(), printf, and headers."}},{"@type":"Question","name":"Can AI detect errors in a C Hello World program?","acceptedAnswer":{"@type":"Answer","text":"Yes. AI-assisted tools can spot missing semicolons, unclosed braces, a forgotten #include, or an incorrect return type, and explain how to fix each issue, which speeds up debugging for new programmers."}}]}],"@id":"https://www.guru99.com/c-hello-world-program.html#schema-1126970","isPartOf":{"@id":"https://www.guru99.com/c-hello-world-program.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/c-hello-world-program.html#webpage"}}]}
```
