You see things on a screen via the video output port of a computer when the screen is plugged into it. At the time of writing this, computers can display all sorts of things on these screens from computer games, films and text plus many other things. I want to focus on the text output, because especially when you start programming the majority of things will heavily involve manipulating text on screen not just by outputs but what you input also with a keyboard.
stdio.h is C’s standard input/output header: a file that describes ready-made tools for getting information into and out of a program. Programmers use it when they need to read what you type, display messages or read and write files. They add
#include <stdio.h>at the start of their code so the compiler knows how to use these tools. These include printf, which can display text on your screen, saving programmers from having to build that feature themselves.
The next part is the function definition as follows; this contains and provides the actual code of the program, however you can have multiple function definitions within a C program.
#include <stdio.h>
int main() {}Then overall you have the actual code of the program as follows
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
} printf is declared in the <stdio.h>
header.
"Hello, World!\n"
is a string of text.
\n starts a new line.
; marks
the end of the statement.
return ends the main function.
0 is an exit status sent to the operating
system.
By convention, 0 means the program finished
successfully.
A non-zero value usually indicates an error.
In modern C, reaching the closing brace of main has the
same effect as writing return 0;. However, including it
explicitly can make the programmer’s intention clearer.