C Hello World Tutorial
This tutorial demonstrates how to create and run your first C program, the famous "Hello, World!" example. It introduces the basics of C syntax and program execution.
1. Write Your First C Program
Create a new file named hello.c and add the following code:
#include <stdio.h>
int main() {
printf("Hello, World!\\n");
return 0;
}
This simple program uses the printf function to print "Hello, World!" to the console.
2. Compile the Program
Use a C compiler to compile your program. For example, if you're using GCC:
gcc hello.c -o hello
This command compiles hello.c into an executable named hello.
3. Run the Program
Execute the compiled program using:
./hello
You should see the output:
Hello, World!
4. Explanation of the Code
#include <stdio.h>: Includes the standard input/output library.int main(): Defines the main function, the entry point of the program.printf: Prints the specified message to the console.return 0;: Indicates that the program executed successfully.
5. Conclusion
Congratulations! You’ve written and run your first C program. This "Hello, World!" program is the foundation for learning more advanced C concepts.
×