In this article, we are going to learn How to print “Hello, World!” on the console in C programming.“Hello, World!” is the first program in any language that you learn so we will do this with very basic syntax so it becomes easy for you to understand. The concept of C, that you need to do this is just Console Output and printf() function.
C Program to print “Hello, World!”
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
Output
Hello, World!
Code Explaination of Program:
- First we need to include a header file in our program. We can include any header file in a C program by using the #include preprocessor directive. Once compiler hit this directive it look for the given header file and includes its code in our program.We are including because we need printf() function to print “Hello, World!” and this function is available in this file.
- Next we have is the main() function which will be always present in all your C Programs and it is the starting point of any C Program.When we say starting point it means, program will start executing from this function itself.
- Inside main() function, we have printf() function which is used to print anything on console. To print a string like “Hello, World!” we need to pass it in double quotes.This function accepts any C formatted string output and send it to your program console to print.
- Finally we are returning 0 from the main() function to exit the program gracefully. It means after this line your program will end and closing bracket will unwind the function stack to terminate the function program.
Conclusion
We hope you have learned your first program and are ready to learn more!!