
The First Program in C: "Hello, World!"
Created on 7 January, 2025 • Tutorials • 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
#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.
int main()
- This defines the main function, where the program starts execution.
int
indicates that the function returns an integer value.
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.
return 0;
- This statement indicates that the program has executed successfully.
- A
0
value is returned to the operating system.
Output
When you run the program, the output will appear as:
Hello, World!
Popular posts
-
The First Program in C: "Hello, World!"Tutorials • 179 views
-
Why is C ImportantTutorials • 171 views
-
The History of the C Programming LanguageTutorials • 160 views
-
Next.js 15.2NextJs • 105 views