In this post, I'm gonna share Hello, World! Program in C with you, in easy to understandable way.
In order to understand Hello, World! Program in C, you should have the knowledge of the following post:
Hello, World! Program in C
(hash)include
(hash)include
int main()
{
// printf() displays the string inside quotation
printf("Hello, World!");
getch();
return 0;
}
Output:
Hello, World!
How "Hello, World!" program works?
- The #include is a preprocessor directive that tells the compiler to include the contents of any header file like stdio.h (Standard Input Outout).
- stdio.h file contains functions such as scanf() and printf() to take input and display output respectively.
- The program will through an error, If you use the printf() function without using #include
- The execution of a C program starts with the main() function.
- printf() is a library function to send "String" to the console. In this program, printf() displays "Hello, World!" text on the screen.
- One more additional thing is getch() function, is basically a p redefine function of conio.h (console input output) header file, used to hold the screen until the user press any key.
- Basically what happen?, when the program get execute, after the whole execution it will automatically get exit. In order to avoid this, we have to use getch() or getche() function.
- The return 0; is the "Exit status" of the program. We can say that, the program ends with this statement.
Conclusion In this post I have shared the Hello, World! Program in C in easy to understandable manner.
I hope you have got useful content from here. I have presented my best in front o you.
Thanks for Visit!
original Credit: www.dheerajpatidar.com