Course Content
C Tutorial
About Lesson

Hello World Program

The “Hello, World!” program is a classic introductory program in the world of programming languages. In C, it’s the simplest code that demonstrates the basic structure and syntax of the language. This program serves as a starting point for beginners learning C programming.

Writing the “Hello, World!” Program in C

To create the “Hello, World!” program in C, you only need a few lines of code. Here’s an example:

#include <stdio.h>

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

Breaking Down the Code

Let’s understand the code:

  • #include <stdio.h>: This line includes the standard input-output library in C, which contains functions like printf() for printing output to the console.
  • int main() { }: In C, every program must have a main() function. It serves as the entry point of the program.
  • printf("Hello, World!n");: This line uses the printf() function to display the “Hello, World!” message on the screen. The n represents a newline character, causing the cursor to move to the next line after printing.
  • return 0;: The return statement inside the main() function signifies the end of the program. In this case, 0 indicates successful execution.

Compiling and Running the Program

To run the “Hello, World!” program in C:

  1. Use a C compiler like GCC (GNU Compiler Collection) to compile the code.
  2. Execute the compiled program.

Why “Hello, World!” in C is Important

This simple program may seem trivial, but it’s instrumental in understanding the fundamental syntax and structure of the C language. It introduces key concepts like functions, libraries, and basic output