C Hello World
The “Hello World” program in C is the simplest program you can write. It demonstrates the basic syntax and structure of a C program by printing “Hello, World!” to the console.
Hello World Program Code
main.c
</>
Copy
#include <stdio.h>
int main() {
// Print "Hello, World!" to the console
printf("Hello, World!\n");
return 0;
}
Explanation:
- #include <stdio.h>: This line includes the Standard Input Output library which is required for using the
printf()
function. - int main(): This is the main function where the program execution begins. In C, every executable program must have a
main()
function. - { … }: The curly braces enclose the body of the
main()
function. - printf(“Hello, World!\n”); : This statement calls the
printf()
function with the argument “Hello, World!”. The function prints this string to the console.
The\n
inside the string is an escape sequence that creates a new line after printing. - return 0;: This statement ends the
main()
function and returns 0 to the operating system, indicating that the program finished successfully.
This basic “Hello World” program introduces you to the structure and syntax of a C program. Understanding these fundamental components is essential as you progress to the next concepts in C.