The First Program in C: "Hello, World!"

Created on 7 January, 2025Tutorials • 180 views

The "Hello, World!" program is often the first program beginners write when learning a new programming language. Its purpose is to demonstrate the basic structure of a C program and how to display output to the screen.

The "Hello, World!" program is often the first program beginners write when learning a new programming language. Its purpose is to demonstrate the basic structure of a C program and how to display output to the screen.



#include <stdio.h> // Includes the standard input/output library
int main() {
printf("Hello, World!\n") // Prints "Hello, World!" followed by a new line
return 0; // Indicates successful program termination
}



Explanation of the Code

  1. #include
  • This line includes the Standard Input/Output library (stdio.h) in the program.
  • It provides the printf function, which is used to display output.
  1. int main()
  • This defines the main function, where the program starts execution.
  • int indicates that the function returns an integer value.
  1. printf("Hello, World!\n");
  • printf is a function used to print text to the screen.
  • "Hello, World!" is the text that will be displayed.
  • \n is an escape sequence that moves the cursor to a new line after printing.
  1. return 0;
  • This statement indicates that the program has executed successfully.
  • 0 value is returned to the operating system.


Output

When you run the program, the output will appear as:


Hello, World!